ISqlDeleteBuilder.Delete(string table, string schema) Method
.NET Standard 2.x
Creates a SQL DELETE statement and specifies the name and the schema of the table or view from which the rows are to be removed.
Namespace: SnapObjects.Data
Assembly: SnapObjects.Data.dll
Syntax
ISqlDeleteBuilder Delete(string table, string schema);
Parameters
table
System.String
The name of the table or view from which the rows are to be removed.
schema
System.String
The schema of the table or view from which the rows are to be removed.
Returns
SnapObjects.Data.ISqlDeleteBuilder
Returns the current ISqlDeleteBuilder
object.
Examples
The following code example demonstrates how to use the ISqlDeleteBuilder.Delete(string table, string schema) method. It builds a SQL DELETE statement to delete the records whose name="English" from the "Department" table and specifies the schema of the "Department" table.
using SnapObjects.Data;
using System;
namespace Appeon.ApiDoc.ISqlDeleteBuilderExamples
{
public class DeleteExample
{
private SchoolContext _context;
public DeleteExample(SchoolContext dataContext)
{
// Sets the Data Context
_context = dataContext;
}
public void Example2()
{
// Declares SqlDeleteBuilder.
var sqlbuilder = new SqlDeleteBuilder();
// Builds a SQL DELETE statement to delete the records whose name="English" from the "Department" table.
sqlbuilder.Delete("Department", "dbo")
.WhereValue("name", SqlBinaryOperator.Equals, "English");
// Converts the syntax 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:
DELETE
FROM [dbo].[Department]
WHERE ([name] = N'English')
*/
}
}
}
Applies to
.NET Standard
2.x