Show / Hide Table of Contents

    ISqlDeleteBuilder.Delete(string table) Method

    .NET Standard 2.x

    Creates a SQL DELETE statement and specifies the name 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);
    

    Parameters

    table System.String

    The name 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) method. It builds a SQL DELETE statement to delete the records whose name="English" from 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 Example1()
            {
    
                // 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")
                    .WhereValue("name", SqlBinaryOperator.Equals, "English");
    
                // Converts the syntax to raw SQL for the database corresponding to data context.
                string sql = sqlbuilder.ToSqlString(_context);
    
                Console.WriteLine(sql);
    
                /*This code produces the following output:
                
                DELETE
                FROM [Department]
                WHERE ([name] = N'English')     
                */
            }
        }
    }
    

    Applies to

    .NET Standard

    2.x

    Back to top Generated by Appeon