ModelSqlBuilder.GetBuilder<TModel>(DataContext context) Method
.NET Standard 2.x
Creates a ModelSqlBuilder object with the specified model class and data context.
Namespace: SnapObjects.Data
Assembly: SnapObjects.Data.dll
Syntax
public static ModelSqlBuilder GetBuilder<TModel>(DataContext context)
Type Parameters
TModel
The type of the model class used to create the ISqlBuilder
object.
Parameters
context
SnapObjects.Data.DataContext
The DataContext
object used to generate SQL statement.
Returns
SnapObjects.Data.ModelSqlBuilder
Returns the newly created ModelSqlBuilder
object.
Examples
The following code example returns a ModelSqlBuilder
object according to the specified model class.
using Appeon.ApiDoc.Models.School;
using SnapObjects.Data;
using System;
namespace Appeon.ApiDoc.ModelSqlBuilderExamples
{
public class GetBuilderExample
{
private readonly SchoolContext _context;
public GetBuilderExample(SchoolContext context)
{
_context = context;
}
public void Example()
{
var build = ModelSqlBuilder.GetBuilder<Person>(_context);
var sql = build.QuerySql;
Console.WriteLine(sql);
/* This code example produces the following output:
SELECT
[PersonID],
[LastName],
[FirstName],
[HireDate],
[EnrollmentDate],
[Discriminator]
FROM [dbo].[Person]
*/
}
}
}
Example Refer To
Model Class: Person
Applies to
.NET Standard
2.x