SqlInsertBuilder.SqlInsertBuilder(string name = "") Constructor
.NET Standard 2.x
Initializes a new instance of the SqlInsertBuilder class.
Namespace: SnapObjects.Data
Assembly: SnapObjects.Data.dll
Syntax
public SqlInsertBuilder(string name = "");
Parameters
name
System.String
(Optional) The name for this SqlInsertBuilder object.
Examples
The following code example demonstrates how to create a SqlInsertBuilder object.
using SnapObjects.Data;
using System;
namespace Appeon.ApiDoc.SqlInsertBuilderExamples
{
public class SqlInsertBuilderExample
{
private readonly SchoolContext _context;
public SqlInsertBuilderExample(SchoolContext dataContext)
{
// Sets data context.
_context = dataContext;
}
public void Example()
{
// Creates a SqlInsertBuilder object.
ISqlInsertBuilder insert = new SqlInsertBuilder();
// Uses this object to build the INSERT statement.
insert.Insert("Course");
insert.Column("Courseid", SqlBuilder.Parameter<int>("id"));
insert.Column("Title", SqlBuilder.Parameter<string>("title"));
// Outputs the generated SQL statement.
var sql = insert.ToSqlString(_context);
Console.WriteLine(sql);
/*This code produces the following output:
INSERT INTO Course([Courseid],
[Title]) VALUES(@id,
@title)
*/
}
}
}
Applies to
.NET Standard
2.x