Show / Hide Table of Contents

    ISqlWhereBuilder.RemoveWhere() Method

    .NET Standard 2.x

    Removes all of the search conditions that have been added to the WHERE clause.

    Namespace: SnapObjects.Data

    Assembly: SnapObjects.Data.dll

    Syntax

       bool RemoveWhere();
    

    Returns

    System.Boolean

    Returns true if the removal is successful, and returns false if there were no search conditions in the WHERE clause.

    Examples

    The following code example demonstrates how to use the RemoveWhere method to remove the condition from the WHERE clause.

    using SnapObjects.Data;
    using System;
    
    namespace Appeon.ApiDoc.ISqlWhereBuilderExamples
    {
        public class RemoveWhereExample
        {
            private readonly SchoolContext _context;
    
            public RemoveWhereExample(SchoolContext dataContext)
            {
                // Sets data context.
                _context = dataContext;
            }
    
            public void Example1()
            {
    
                // Declares SqlQueryBuilder.
                ISqlQueryBuilder sqlQueryBuilder = new SqlQueryBuilder();
    
                // Defines a SQL statement.
                sqlQueryBuilder.Select("Title")
                                .From("Course")
                                .WhereRaw("DepartmentID = 1");
    
                // Shows the statement before removing the WHERE clause.
                Console.WriteLine("The SQL SELECT statement (before removed): \n{0}",
                    sqlQueryBuilder.ToSqlString(_context));
    
                // Removes the WHERE clause.
                sqlQueryBuilder.RemoveWhere();
    
                // Shows the statement after removing the WHERE clause.
                Console.WriteLine();
                Console.WriteLine("The SQL SELECT statement (after removed): \n{0}",
                    sqlQueryBuilder.ToSqlString(_context));
    
                /*This code produces the following output:
    
                The SQL SELECT statement (before removed):
                SELECT
                 [Title]
                FROM [Course]
                WHERE ([DepartmentID] = 1)
    
                The SQL SELECT statement (after removed):
                SELECT
                 [Title]
                FROM [Course]
               */
            }
        }
    }
    

    Applies to

    .NET Standard

    2.x

    Back to top Generated by Appeon