ISqlWhereAndOr<TBuilder>.AndWhereIsNotNull(string left) Method
.NET Standard 2.x
Adds the AND
logical operator and a search condition to the WHERE clause; and uses IS NOT NULL
operator to search for values that are not null.
Namespace: SnapObjects.Data
Assembly: SnapObjects.Data.dll
Syntax
TBuilder AndWhereIsNotNull(string left);
Parameters
left
System.String
A SQL expression on the left of the IS NOT NULL
operator.
Returns
TBuilder
Returns the ISqlWhereAndOr
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 AndWhereIsNotNull method to add an AND 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 AndWhereIsNotNullExample
{
private readonly SchoolContext _context;
public AndWhereIsNotNullExample(SchoolContext dataContext)
{
// Sets data context.
_context = dataContext;
}
public void Example()
{
// Declares SqlQueryBuilder.
var sqlbuilder = new SqlQueryBuilder();
// Defines a SQL statement, and adds an AND IS NOT NULL condition: Title cannot be null.
sqlbuilder.Select("*")
.From("Course")
.Where("CourseID", SqlBinaryOperator.GreaterThan,
SqlBuilder.Parameter<int>("courid"))
.AndWhereIsNotNull("Title");
string sql = sqlbuilder.ToSqlString(_context);
Console.WriteLine(sql);
/*This code produces the following output:
SELECT
*
FROM [Course]
WHERE ([CourseID] > @courid
AND [Title] IS NOT NULL)
*/
}
}
}
Applies to
.NET Standard
2.x