ModelSqlBuilder.GetQuerySql(string selectName) Method
.NET Standard 2.x
Namespace: SnapObjects.Data
Assembly: SnapObjects.Data.dll
Gets the SQL SELECT statement based on the definition in the model class, the specified select list, and the data context.
Syntax
public string GetQuerySql(string selectName)
Parameters
selectName
Systme.String
The name of the select list predefined in the model class.
Returns
System.String
Returns the newly generated SQL SELECT statement.
Examples
The following code example gets the SQL SELECT statement from the associated model of the ModelSqlBuilder
object.
using Appeon.ApiDoc.Models.School;
using SnapObjects.Data;
using System;
namespace Appeon.ApiDoc.ModelSqlBuilderExamples
{
public class GetQuerySqlExample
{
private readonly SchoolContext _context;
public GetQuerySqlExample(SchoolContext context)
{
_context = context;
}
public void Example()
{
ModelSqlBuilder build;
// Creates a ModelSqlBuilder object
build = ModelSqlBuilder.GetBuilder<CourseInfo>(_context);
string query = build.GetQuerySql("SelectCourse");
Console.WriteLine("GetQuerySql = {0}", query);
/* The code produces the following output:
GetQuerySql = SELECT
[Title]
FROM [dbo].[Course]
WHERE ([DepartmentId] = @deptId)
*/
}
}
}
Example Refer To
Model Class: CourseInfo
Applies to
.NET Standard
2.x