SqlBuilder.Where(string left, string right) Method
.NET Standard 2.x
Creates an ISqlWhereCondition
object which represents a search condition that can be used when building the WHERE clause. Specifies SQL expressions on both the left and right of the operator. The operator is '='.
Namespace: SnapObjects.Data
Assembly: SnapObjects.Data.dll
Syntax
public static ISqlWhereCondition Where(string left, string right);
Parameters
left
System.String
A SQL expression on the left of the operator.
right
System.String
A SQL expression 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 uses the Where method to specify the column which associates multiple tables.
using SnapObjects.Data;
using System;
namespace Appeon.ApiDoc.SqlBuilderExamples
{
public class WhereExample
{
private SchoolContext _context;
public WhereExample(SchoolContext dataContext)
{
// Sets Data Context.
_context = dataContext;
}
public void Example1()
{
var sqlquerybuilder = new SqlQueryBuilder();
// Defines a WHERE condition.
var where = SqlBuilder.Where("d.DepartmentID", "c.DepartmentID");
// Creates a SQL statement.
var query = sqlquerybuilder
.Select(new string[] { "d.name", "c.title" })
.From("Department", "d")
.From("Course", "c")
.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
[d].[name],
[c].[title]
FROM [Department] AS [d] ,
[Course] AS [c]
WHERE ([d].[DepartmentID] = [c].[DepartmentID])
*/
}
}
}
Applies to
.NET Standard
2.x