SqlBuilder.WhereValue(string left, object value) Method
.NET Standard 2.x
Creates an ISqlWhereCondition
object which represents a search condition that can be used when building 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
public static ISqlWhereCondition 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.ISqlWhereCondition
Returns the ISqlWhereCondition
object which can be used to add more search conditions to the WHERE clause.
Examples
The following code example demonstrates how to use the WhereValue method to specify a WHERE condition.
using SnapObjects.Data;
using System;
namespace Appeon.ApiDoc.SqlBuilderExamples
{
public class WhereValueExample
{
private SchoolContext _context;
public WhereValueExample(SchoolContext dataContext)
{
// Sets Data Context.
_context = dataContext;
}
public void Example1()
{
var sqlquerybuilder = new SqlQueryBuilder();
// Defines a WHERE condition.
var where = SqlBuilder.WhereValue("name", "English");
// Creates a SQL statement.
var query = sqlquerybuilder
.Select("*")
.From("Department")
.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 [Department]
WHERE ([name] = N'English')
*/
}
}
}
Applies to
.NET Standard
2.x