SqlModelMapper.SqlModelMapper(DataContext context) Constructor
.NET Standard 2.x | Current Version (1.0.1)
Initializes a new instance of the SqlModelMapper
class with a DataContext
object.
Namespace: SnapObjects.Data
Assembly: SnapObjects.Data.dll
Syntax
public SqlModelMapper(DataContext context);
Parameters
context
SnapObjects.Data.DataContext
A DataContext object, which includes the context information for creating a database session.
Remarks
In addition to manually creating a SqlModelMapper
instance, you can also use an initialized DataContext
object to access the DataContext.SqlModelMapper property and get a SqlModelMapper
instance.
Examples
The following code example demonstrates how to create a SqlModelMapper
object.
using SnapObjects.Data;
using System;
namespace Appeon.ApiDoc.SqlModelMapperExamples
{
public class SqlModelMapperExample
{
private SchoolContext _context;
public SqlModelMapperExample(SchoolContext dataContext)
{
// Sets the data context.
_context = dataContext;
}
public void Example()
{
// Creates the SqlModelMapper object by a DataContext object.
var mapper = new SqlModelMapper(_context);
Console.WriteLine("{0}.",
mapper.ToString());
// In addition to using the constructor, you can also use the
// DataContext.SqlModelMapper property to get the ISqlModelMapper object.
var mapper2 = _context.SqlModelMapper;
/*This code produces the following output:
SnapObjects.Data.SqlModelMapper.
*/
}
}
}
Applies to
.NET Standard
2.x