IQueryWhereBuilder.WhereValue(string left, SqlBinaryOperator sqlOperator, 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.
Namespace: SnapObjects.Data
Assembly: SnapObjects.Data.dll
Syntax
IQueryAndOrBuilder<TModel> WhereValue(string left, SqlBinaryOperator sqlOperator, object value)
Parameters
left
System.String
An expression on the left of the operator.
SqlBinaryOperator
SnapObjects.Data.SqlBinaryOperator
An enumeration value of SqlBinaryOperator
, which is the operator to test the expression on the left and the value on the right.
value
System.Object
A specific value on the right of the operator.
Returns
Returns an IQueryAndOrBuilder<TModel>
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 "Department" table must not use "Economics" as its Name value.
using Appeon.ApiDoc.Models.School;
using SnapObjects.Data;
using System;
using System.Threading.Tasks;
namespace Appeon.ApiDoc.IQueryWhereBuilderExamples
{
public class WhereValueExample
{
private SchoolContext _context;
public WhereValueExample(SchoolContext dataContext)
{
// Sets Data Context
_context = dataContext;
}
public async Task<int> Example2()
{
// Get a QueryBuilder.
var Builder = _context.SqlModelMapper.GetQueryBuilder<Department>();
// 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.
Builder.WhereValue("Name", SqlBinaryOperator.NotEquals, "Economics");
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: 2
Name: English
DepartmentID: 7
Name: Mathematics
DepartmentID: 10
Name: New Department
*/
}
}
}
Example Refer To
Model Class: Department
Applies to
.NET Standard
2.x