Conditions
Table Of Contents
Conditions And Query
This is list of all the Conditions that can be used to build your Query instance.
The conditions are expressed as methods of the Query class and can be chained together to form complex queries.
To learn about how to craft the Query instance using conditions go to the Filtering section of the documentation.
Supported By All C# Data Types
The following conditions can be used by all C# data types:
-
Equals will search for rows in which the value of the specified column is equals the value passed in.
When working with DateTime this will take into account also the Time portion of the DateTime.
When working with string this can be affected by database settings like collation.
-
NotEquals will search for rows in which the value of the specified column is not equals the value passed in.
When working with DateTime this will take into account also the Time portion of the DateTime.
When working with string this can be affected by database settings like collation.
-
IsNull will search for rows in which the value of the specified column is null.
-
IsNotNull will search for rows in which the value of the specified column is not null.
Numeric Data Types
The following conditions can be used by all C# numeric data types like long, int, short, byte, decimal, double:
-
Equals will search for rows in which the value of the specified column is equals the value passed in.
-
NotEquals will search for rows in which the value of the specified column is not equals the value passed in.
-
GreaterThan will search for rows in which the value of the specified column is greater than the value passed in.
-
LessThan will search for rows in which the value of the specified column is less than the value passed in.
-
GreaterThanOrEquals will search for rows in which the value of the specified column is greater than or equals to the value passed in.
-
LessThanOrEquals will search for rows in which the value of the specified column is less than or equals to the value passed in.
Integer Data Types
Refers to long, int, short, byte.
All the conditions supported by the Numeric Data Types are supported.
In addition, the following are also supported:
-
In translates to an IN clause in SQL.
Searches for rows in which the specified column is contained within the collection of values passed in.
Takes an array of values for the corresponding datatype: long[], int[], short[], byte[]
-
NotIn translates to a NOT IN clause in SQL.
Searches for rows in which the specified column is not contained within the collection of values passed in.
Takes an array of values for the corresponding datatype: long[], int[], short[], byte[]
String Data Type
The following conditions can be used when working with strings:
Whether the comparisons are case-sensitive will depend on configurations in your database like the collation.
-
Equals will search for rows in which the value of the specified column is equals the value passed in.
-
NotEquals will search for rows in which the value of the specified column is not equals the value passed in.
-
StartsWith will search for rows in which the value of the specified column starts with the value passed in.
-
EndsWith will search for rows in which the value of the specified column ends with the value passed in.
-
DoesNotStartWith will search for rows in which the value of the specified column does not start with the value passed in.
-
DoesNotEndWith will search for rows in which the value of the specified column does not end with the value passed in.
-
Like will search for rows in which the value of the specified column contains the value passed in.
-
NotLike will search for rows in which the value of the specified column does not contain the value passed in.
-
In translates to an IN clause in SQL.
Searches for rows in which the specified column is contained within the collection of values passed in.
Takes an array of values for the corresponding datatype: string[]
-
NotIn translates to a NOT IN clause in SQL.
Searches for rows in which the specified column is not contained within the collection of values passed in.
Takes an array of values for the corresponding datatype: string[]
DateTime Including The Time Portion
The following conditions will perform the comparisons using the DateTime including the Time portion (Hours, Minutes, Seconds, Milliseconds):
-
Equals will search for rows in which the value of the specified column is equals the value passed in.
-
NotEquals will search for rows in which the value of the specified column is not equals the value passed in.
-
GreaterThan will search for rows in which the value of the specified column is greater than the value passed in.
-
LessThan will search for rows in which the value of the specified column is less than the value passed in.
-
GreaterThanOrEquals will search for rows in which the value of the specified column is greater than or equals to the value passed in.
-
LessThanOrEquals will search for rows in which the value of the specified column is less than or equals to the value passed in.
DateTime Date Portion Only
The following conditions will perform the comparisons using the DateTime including only the Date portion:
-
EqualsDate will search for rows in which the Date portion of the specified column's value is equals the Date portion of the value passed in.
-
NotEqualsDate will search for rows in which the Date portion of the specified column's value is not equals the Date portion of the value passed in.
-
GreaterThanDate will search for rows in which the Date portion of the specified column's value is greater than the Date portion of the value passed in.
-
LessThanDate will search for rows in which the Date portion of the specified column's value is less than the Date portion of the value passed in.
-
GreaterThanOrEqualsDate will search for rows in which the Date portion of the specified column's value is greater than or equals to the Date portion of the value passed in.
-
LessThanOrEqualsDate will search for rows in which the Date portion of the specified column's value is less than or equals to the Date portion of the value passed in.
DateTime Year Only
The Year is passed in as an integer.
Maps to the YEAR function in SQL Server
Can be used for example to get all records for a particular year.
The following conditions will perform the comparisons using only the Year:
-
EqualsYear will search for rows in which the Year portion of the specified column's value is equals the Year passed in as an integer.
-
NotEqualsYear will search for rows in which the Year portion of the specified column's value is not equals the Year passed in as an integer.
-
GreaterThanYear will search for rows in which the Year portion of the specified column's value is greater than the Year passed in as an integer.
-
LessThanYear will search for rows in which the Year portion of the specified column's value is less than the Year passed in as an integer.
-
GreaterThanOrEqualsYear will search for rows in which the Year portion of the specified column's value is greater than or equals to the Year passed in as an integer.
-
LessThanOrEqualsYear will search for rows in which the Year portion of the specified column's value is less than or equals to the Year passed in as an integer.
DateTime Month Only
The Month is passed in as an integer.
Maps to the MONTH function in SQL Server
Can be used for example to get all records for a particular month regardless of the year.
The following conditions will perform the comparisons using only the Month:
-
EqualsMonth will search for rows in which the Month portion of the specified column's value is equals the Month passed in as an integer.
-
NotEqualsMonth will search for rows in which the Month portion of the specified column's value is not equals the Month passed in as an integer.
-
GreaterThanMonth will search for rows in which the Month portion of the specified column's value is greater than the Month passed in as an integer.
-
LessThanMonth will search for rows in which the Month portion of the specified column's value is less than the Month passed in as an integer.
-
GreaterThanOrEqualsMonth will search for rows in which the Month portion of the specified column's value is greater than or equals to the Month passed in as an integer.
-
LessThanOrEqualsMonth will search for rows in which the Month portion of the specified column's value is less than or equals to the Month passed in as an integer.
DateTime Day Only
The Day is passed in as an integer.
Refers to the day of the month. For example the 15th of the month.
Maps to the DAY function in SQL Server
Can be used for example to get all records for a particular day of the month regardless of the year and month.
The following conditions will perform the comparisons using only the Day:
-
EqualsDay will search for rows in which the Day portion of the specified column's value is equals the Day passed in as an integer.
-
NotEqualsDay will search for rows in which the Day portion of the specified column's value is not equals the Day passed in as an integer.
-
GreaterThanDay will search for rows in which the Day portion of the specified column's value is greater than the Day passed in as an integer.
-
LessThanDay will search for rows in which the Day portion of the specified column's value is less than the Day passed in as an integer.
-
GreaterThanOrEqualsDay will search for rows in which the Day portion of the specified column's value is greater than or equals to the Day passed in as an integer.
-
LessThanOrEqualsDay will search for rows in which the Day portion of the specified column's value is less than or equals to the Day passed in as an integer.
Crafting Queries Using Conditions
For information on how to craft the Query instance using conditions go to the Filtering section of the documentation.