Show / Hide Table of Contents

    ISqlWhereBuilder.WhereValue(string left, object value) Method

    .NET Standard 2.x

    Creates a WHERE clause, and adds a search condition to the WHERE clause. Specifies a SQL expression on the left of the operator and a specific value on the right of the operator. The operator is '='.

    Namespace: SnapObjects.Data

    Assembly: SnapObjects.Data.dll

    Syntax

      ISqlWhereAndOr WhereValue(string left, object value);
    

    Parameters

    left System.String

    An expression on the left of the operator.

    value System.Object

    A specific value on the right of the operator.

    Returns

    SnapObjects.Data.ISqlWhereAndOr

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

    Examples

    The following code example uses the WhereValue method to specify that data retrieved from the "Course" table must have "Physics" as its Title value.

    using SnapObjects.Data;
    using System;
    
    namespace Appeon.ApiDoc.ISqlWhereBuilderExamples
    {
        public class WhereValueExample
        {
            private readonly SchoolContext _context;
    
            public WhereValueExample(SchoolContext dataContext)
            {
                // Sets data context.
                _context = dataContext;
            }
    
            public void Example1()
            {
    
                //  Declares SqlQueryBuilder.
                var sqlbuilder = new SqlQueryBuilder();
    
                // Defines a SQL statement, and sets the WHERE condition: Title = "Physics".
                sqlbuilder.Select("*")
                    .From("Course")
                    .WhereValue("Title", "Physics");
    
                string sql = sqlbuilder.ToSqlString(_context);
    
                Console.WriteLine(sql);
    
                /*This code produces the following output:
    
                SELECT
                *
                FROM [Course]
                WHERE ([Title] = N'Physics')
               */
            }
        }
    }
    

    Applies to

    .NET Standard

    2.x

    Back to top Generated by Appeon