ISqlWhereAndOr<TBuilder>.OrWhereIsNotNull(string left) Method
.NET Standard 2.x
Adds the OR
logical operator and a search condition to the WHERE clause; and uses the IS NOT NULL
operator to search for values that are not null.
Namespace: SnapObjects.Data
Assembly: SnapObjects.Data.dll
Syntax
TBuilder OrWhereIsNotNull(string left);
Parameters
left
System.String
A SQL expression on the left of the IS NOT 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 OrWhereIsNotNull method to add an OR IS NOT NULL condition to the WHERE clause. In this example, the IS NOT NULL condition specifies that the Title value cannot be null.
using SnapObjects.Data;
using System;
namespace Appeon.ApiDoc.ISqlWhereAndOrExamples
{
public class OrWhereIsNotNullExample
{
private readonly SchoolContext _context;
public OrWhereIsNotNullExample(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 NOT NULL condition: Title cannot be null.
sqlbuilder.Select("*")
.From("Course")
.Where("CourseID", SqlBinaryOperator.GreaterThan,
SqlBuilder.Parameter<int>("courid"))
.OrWhereIsNotNull("Title");
string sql = sqlbuilder.ToSqlString(_context);
Console.WriteLine(sql);
/*This code produces the following output:
SELECT
*
FROM [Course]
WHERE ([CourseID] > @courid
OR [Title] IS NOT NULL)
*/
}
}
}
Applies to
.NET Standard
2.x