Show / Hide Table of Contents

    SqlBuilder.EmbeddedWhereIsNull(string left) Method

    .NET Standard 2.x | Current Version (1.0.1)

    0.5.0-alpha

    1.0.1 (current)

    Creates an ISqlWhereCondition object which represents a search condition that can be used (enclosed in parentheses) when building the WHERE clause. Uses IS NULL operator to search for values that are null.

    Namespace: SnapObjects.Data

    Assembly: SnapObjects.Data.dll

    Syntax

     public static ISqlWhereCondition EmbeddedWhereIsNull(string left);
    

    Parameters

    left System.String

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

    Returns

    SnapObjects.Data.ISqlWhereCondition

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

    Remarks

    The newly created search condition is enclosed in parentheses. If the returned ISqlWhereCondition object is used to add another search condition, both of these search conditions will be enclosed in the same pair of parentheses.

    Examples

    The following code example demonstrates how to use the EmbeddedWhereIsNull method to retrieve records which has null values for the specififed field.

    using SnapObjects.Data;
    using System;
    
    namespace Appeon.ApiDoc.SqlBuilderExamples
    {
        public class EmbeddedWhereIsNullExample
        {
            private SchoolContext _context;
    
            public EmbeddedWhereIsNullExample(SchoolContext dataContext)
            {
                // Sets Data Context.
                _context = dataContext;
            }
    
            public void Example()
            {
                var sqlquerybuilder = new SqlQueryBuilder();
                
                // Defines a WHERE condition.
                var where = SqlBuilder.EmbeddedWhereIsNull("HireDate");
    
                // Creates a SQL statement.
                var query = sqlquerybuilder
                    .Select("*")
                    .From("Person")
                    .Where(where);
    
                // Converts to raw SQL for the database corresponding to the data context.
                string sql = query.ToSqlString(_context);
    
                Console.WriteLine(sql);
                
                /*This code example produces the following output:   
                 
                SELECT
                *
                FROM [Person]
                WHERE ([HireDate] IS NULL)
                */
            }
        }
    }
    

    Applies to

    .NET Standard

    2.x

    Back to top Generated by Appeon