ISqlWhereBuilder.Where(string left, string right) Method
.NET Standard 2.x
Creates a WHERE clause, and adds a search condition to 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
ISqlWhereAndOr 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.ISqlWhereAndOr
Returns the ISqlWhereAndOr
object which can be used to add more search conditions to the current 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.ISqlWhereBuilderExamples
{
public class WhereExample
{
private readonly SchoolContext _context;
public WhereExample(SchoolContext dataContext)
{
// Sets data context.
_context = dataContext;
}
public void Example1()
{
// Declares SqlQueryBuilder.
ISqlQueryBuilder sqlQueryBuilder = new SqlQueryBuilder();
// Defines a SQL statement, and specifies which column to associate two tables.
sqlQueryBuilder.Select("a.CourseID")
.Select("a.Title")
.From("Course", "a")
.From("Department", "b")
.Where("a.DepartmentID", "b.DepartmentID");
// Shows the SQL statement.
Console.WriteLine("The SQL statement: \n{0}",
sqlQueryBuilder.ToSqlString(_context));
// Executes the SQL statement.
var results =
_context.SqlExecutor.Select<DynamicModel>(sqlQueryBuilder);
/*This code produces the following output:
The SQL statement:
SELECT
[a].[CourseID],
[a].[Title]
FROM [Course] AS [a] ,
[Department] AS [b]
WHERE ([a].[DepartmentID] = [b].[DepartmentID])
*/
}
}
}
Applies to
.NET Standard
2.x