Show / Hide Table of Contents

    IQueryAndOrBuilder<TModel>.OrWhereValue(string left, object value) Method

    .NET Standard 2.x

    Adds the OR logical operator and a search condition to the WHERE clause; and specifies a SQL expression on the left the operator and a specific value on the right of the operator. The operator is '='.

    Namespace: SnapObjects.Data

    Assembly: SnapObjects.Data.dll

    Syntax

      IQueryAndOrBuilder<TModel> OrWhereValue(string left, object value);
    

    Parameters

    left System.String

    An expression on the left of the operator.

    value System.Object

    The specific value on the right of the operator.

    Returns

    IQueryAndOrBuilder<TModel>

    Returns anIQueryAndOrBuilder<TModel> 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 OrWhereValue method to add an OR condition to the WHERE clause. In this example, the OR condition specifies that the Title DepartmentID must be equal to 1.

    using Appeon.ApiDoc.Models.School;
    using SnapObjects.Data;
    using System;
    using System.Threading.Tasks;
    
    namespace Appeon.ApiDoc.IQueryAndOrBuilderExamples
    {
        public class OrWhereValueExample
        {
            private SchoolContext _context;
            
            public OrWhereValueExample(SchoolContext dataContext)
            {
                // Sets Data Context
                _context = dataContext;
            }
    
            public async Task<int> Example1()
            {
                // Get a QueryBuilder.
                var Builder = _context.SqlModelMapper.GetQueryBuilder<Department>();
                
                Builder.WhereValue("Name", "Economics")
                       .OrWhereValue("DepartmentID", 1);
                
                var result = (await Builder.LoadAsync()).ToList();
                
                foreach (var dept in result)
                {
                    Console.WriteLine("DepartmentID:    {0}", dept.DepartmentID);
                    Console.WriteLine("Name:            {0}", dept.Name);
                    Console.WriteLine();
                }
                
                return result.Count;
                
                
                /*This code example produces the following output:   
                
                    DepartmentID:    1
                    Name:            Engineering
                    
                    DepartmentID:    4
                    Name:            Economics
                */
            }
        }
    }
    

    Example Refer To

    Model Class: Department

    Applies to

    .NET Standard

    2.x

    Back to top Generated by Appeon