ISqlUpdateBuilder.Update(string table, string schema) Method
.NET Standard 2.x
Creates a SQL UPDATE statement and specifies the name and schema of the table or view from which the rows are to be updated.
Namespace: SnapObjects.Data
Assembly: SnapObjects.Data.dll
Syntax
ISqlUpdateBuilder Update(string table, string schema);
Parameters
table
System.String
The name of the table or view from which the rows are to be updated.
schema
System.String
The name of the schema to which the table or view belongs.
Returns
SnapObjects.Data.ISqlUpdateBuilder
Returns the current ISqlUpdateBuilder
object.
Examples
The following code example demonstrates how to use the Update(string table, string schema) method. It updates the Name value to "Chinese" for the record where DepartmentID=1 in the "Department" table and specifies a schema for the "Department" table.
using SnapObjects.Data;
using System;
namespace Appeon.ApiDoc.ISqlUpdateBuilderExamples
{
public class UpdateExample
{
private SchoolContext _context;
public UpdateExample(SchoolContext dataContext)
{
// Sets Data Context.
_context = dataContext;
}
public void Example2()
{
// Declares SqlQueryBuilder.
var sqlbuilder = new SqlUpdateBuilder();
// Modifies the Name value to "Chinese" for the record where DepartmentID=1 in the "Department" table.
// Specifies the schema of the "Department" table as "dbo".
sqlbuilder.Update("Department", "dbo")
.SetValue("Name", "Chinese")
.Where("DepartmentID", "1");
// Converts to raw SQL for the database corresponding to the data context.
string sql = sqlbuilder.ToSqlString(_context);
Console.WriteLine(sql);
/*This code produces the following output:
UPDATE [dbo].[Department] SET [Name] = N'Chinese'
WHERE ([DepartmentID] = 1)
*/
}
}
}
Applies to
.NET Standard
2.x