IQueryWhereBuilder.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
IQueryAndOrBuilder<TModel> 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
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 have "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> Example1()
{
// 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. The operator is '='.
Builder.WhereValue("Name", "Economics");
var result = (await Builder.LoadAsync()).FirstOrDefault();
Console.WriteLine("DepartmentID: {0}", result.DepartmentID);
Console.WriteLine("Name: {0}", result.Name);
Console.WriteLine("Budget: {0}", result.Budget);
Console.WriteLine("Administrator: {0}", result.Administrator);
Console.WriteLine("StartDate: {0}", result.StartDate);
return result.DepartmentID;
/*This code example produces the following output:
DepartmentID: 4
Name: Economics
Budget: 200000.0000
Administrator: 4
StartDate: 9/1/2007 12:00:00 AM
*/
}
}
}
Example Refer To
Model Class: Department
Applies to
.NET Standard
2.x