ISqlWhereAndOr<TBuilder>.OrWhereIsNull(string left) Method
.NET Standard 2.x
Adds the OR
logical operator and a search condition to the WHERE clause; and uses IS NULL
operator to search for values that are null.
Namespace: SnapObjects.Data
Assembly: SnapObjects.Data.dll
Syntax
TBuilder OrWhereIsNull(string left);
Parameters
left
System.String
A SQL expression on the left of the IS NULL
operator.
Returns
TBuilder
Returns the TBuilder
object which can be used to add more search conditions to the current WHERE clause.
Examples
The following code example demonstrates how to use the OrWhereIsNull method to add an OR IS NULL condition to the WHERE clause. In this example, the IS NULL condition specifies that the Title value must be null.
using SnapObjects.Data;
using System;
namespace Appeon.ApiDoc.ISqlWhereAndOrExamples
{
public class OrWhereIsNullExample
{
private readonly SchoolContext _context;
public OrWhereIsNullExample(SchoolContext dataContext)
{
// Sets data context.
_context = dataContext;
}
public void Example()
{
// Declares SqlQueryBuilder.
var sqlbuilder = new SqlQueryBuilder();
// Defines a SQL statement, and adds an OR IS NULL condition: Title must be null.
sqlbuilder.Select("*")
.From("Course")
.Where("CourseID", SqlBinaryOperator.GreaterThan,
SqlBuilder.Parameter<int>("courid"))
.OrWhereIsNull("Title");
string sql = sqlbuilder.ToSqlString(_context);
Console.WriteLine(sql);
/*This code produces the following output:
SELECT
*
FROM [Course]
WHERE ([CourseID] > @courid
OR [Title] IS NULL)
*/
}
}
}
Applies to
.NET Standard
2.x