Show / Hide Table of Contents

    ISqlWhereAndOr<TBuilder>.AndWhereIsNull(string left) Method

    .NET Standard 2.x

    Adds the AND logical operator and a search condition to the WHERE clause; and uses IS NULL operator to search for values that are null.

    Namespace: SnapObjects.Data

    Assembly: SnapObjects.Data.dll

    Syntax

      TBuilder AndWhereIsNull(string left);
    

    Parameters

    left System.String

    A SQL expression on the left of the IS NULL operator.

    Returns

    TBuilder

    Returns the TBuilder object which can be used to add more search conditions to the current WHERE clause.

    Examples

    The following code example demonstrates how to use the AndWhereIsNull method to add an AND IS NULL condition to the WHERE clause. In this example, the IS NULL condition specifies that the Title value must be null.

    using SnapObjects.Data;
    using System;
    
    namespace Appeon.ApiDoc.ISqlWhereAndOrExamples
    {
        public class AndWhereIsNullExample
        {
            private readonly SchoolContext _context;
    
            public AndWhereIsNullExample(SchoolContext dataContext)
            {
                // Sets data context.
                _context = dataContext;
            }
    
            public void Example()
            {
    
                // Declares SqlQueryBuilder.
                var sqlbuilder = new SqlQueryBuilder();
    
                // Defines a SQL statement, and adds an AND IS NULL condition: Title must be null.
                sqlbuilder.Select("*")
                    .From("Course")
                    .Where("CourseID", SqlBinaryOperator.GreaterThan,
                            SqlBuilder.Parameter<int>("courid"))
                    .AndWhereIsNull("Title");
    
                string sql = sqlbuilder.ToSqlString(_context);
    
                Console.WriteLine(sql);
    
                /*This code produces the following output:
    
                SELECT
                *
                FROM [Course]
                WHERE ([CourseID] > @courid
                AND [Title] IS NULL)
               */
            }
        }
    }
    

    Applies to

    .NET Standard

    2.x

    Back to top Generated by Appeon