Criteria Language Syntax
The criteria language described in this document is used in queries for performed via the Readysell API. It allows you to query for objects using standard object oriented syntax, and also includes several operators used to compare complex values.
Literals
The following table lists the types supported by the criteria language.
Type |
Delimiter |
Description |
---|---|---|
DateTime |
# |
Date and time comparison values. |
Enumeration |
|
Enumeration comparison values. To specify an enumeration value in criteria, use its name enclosed in apostrophes:
|
Guid |
{} |
Guid comparison values. A Guid may only be used in a relational operation with equality or inequality operators. |
Numeric |
|
Numeric comparison values. |
String |
' |
String comparison values. |
Operators
The following tables list available operators.
Aggregation
Operators that perform aggregate operations on collections.
Name |
Description |
Usage |
---|---|---|
Avg |
Evaluates an average of all values in a collection. |
Accounts.Avg(Amount) = 75 |
Count |
Returns the number of objects in a collection. |
Accounts.Count > 1 |
Exists |
Determines whether a collection property contains objects. |
Accounts.Exists |
Max |
Returns the maximum expression value in a collection. |
Accounts.Max(Amount) > 75 |
Min |
Returns the minimum expression value in a collection. |
Accounts.Min(Amount) < 10 |
Sum |
Returns a sum of all expression values in a collection. |
Accounts.Sum(Amount) > 150 |
Binary
Logical expressions that consist of comparison operations between two operands.
Name |
Description |
Usage |
---|---|---|
BitwiseAnd |
Represents the bitwise AND operator. |
Roles & 1 = 1 |
BitwiseOr |
Represents the bitwise OR operator. |
Roles | 253 = 255 |
BitwiseXor |
Represents the bitwise XOR operator. |
Roles ^ 253 = 255 |
Divide |
Represents the division operator. |
Accounts.Max(Amount) / Accounts.Min(Amount) > 10 |
Equal |
Represents the Boolean equality operator. |
Name = 'John' |
Greater |
Represents the Boolean greater-than operator. |
Age > 20 |
GreaterOrEqual |
Represents the Boolean greater-than-or-equal-to operator. |
Age >= 20 |
Less |
Represents the Boolean less-than operator. |
Age < 20 |
LessOrEqual |
Represents the Boolean less-than-or-equal-to operator. |
Age <= 20 |
Like |
Represents the LIKE operator that determines whether a specific character string matches a specified pattern. The following wildcard characters are supported:
|
Name like 'Jo%' or Name like '%ob' |
Minus |
Represents the subtraction operator. |
Age - 30 > 0 |
Modulo |
Represents the modulus operator (computes the remainder after dividing its first operand by its second). |
Age % 50 = 0 |
Multiply |
Represents the multiplication operator. |
Accounts.Sum(Amount) * 20 >= 3000 |
NotEqual |
Represents the Boolean inequality operator. |
Name != 'John' |
Plus |
Represents the addition operator. Note: You can also use this operator to concatenate strings. |
Age + 50 = 100 |
Function Operators
The table below lists the available logical and string management operators.
Name |
Description |
Usage |
---|---|---|
Concat |
Concatenates one or more strings. |
Name like Concat('%J', 'o%') |
Iif |
Returns one of two values depending upon the value of a logical expression. The function requires three operands:
|
(Iif (Accounts.Sum(Amount) > 150, 1, 0) = 1) |
IsNull |
Compares the first operand with the null value. This function requires one or two operands. The value returned depends upon the number of arguments.
|
IsNull(Name) |
Len |
Returns the length of the string specified by an operand. |
Len(Name) > 3 |
Lower |
Converts all characters in a string operand to lowercase. |
Lower(Name) like '%jo%' |
Substring |
Returns a substring extracted from the specified string. If two operands are passed the substring will be extracted from the beginning of the original string. The operands should be defined as follows:
|
Substring(Name, 0, 2) = 'Bo' |
Trim |
Returns a string containing a copy of a specified string with no leading or trailing spaces. This function requires a single operand that refers to the original string. |
Trim(Name) = 'Bob' |
Upper |
Converts all characters in a string operand to uppercase. |
Upper(Name) like '%JO%' |
Group
Logical expressions which group two or more operands with a logical AND or OR.
Name |
Description |
Usage |
---|---|---|
And |
Groups operands with logical AND. |
Name = 'John' and Age = 30 |
Or |
Groups operands with logical OR. |
Name = 'John' or Age = 30 |
Unary
Unary operators which perform operations on a single expression.
Name |
Description |
Usage |
---|---|---|
BitwiseNot |
Represents the bitwise NOT operator. |
~Roles = 251 |
IsNull |
Represents the operator which determines whether or not a given expression is NULL. |
Name is null |
Minus |
Represents the unary negation (-) operator. |
-Age = -20 |
Not |
Represents the logical NOT. |
not (Name = 'John' or Age = 30) |
Plus |
Represents the unary plus (+) operator. |
Age = +10 |
Miscellaneous
Name |
Description |
Usage |
---|---|---|
Between |
Determines whether the expression lies between the specified range of values. |
Age between (20, 40) |
In |
Determines whether a value matches any value in the specified list. |
Name in ('John', 'Bob', 'Nick') |
Operator Precedence
When an expression contains multiple operators, operator precedence controls the order in which the elements of the expression are evaluated.
- Literal values
- Parameters
- Identifiers
- OR (left-associative)
- AND (left-associative)
- '.' relationship qualifier (left-associative)
- ==, !=, Like
- <, >, <=, >=
- -, + (left-associative)
- *, /, % (left-associative)
- NOT
- unary -
- In
- Iif
- Trim(), Len(), Substring(), IsNull()
- '[]' (for set-restriction)
- '()'
The default precedence can be changed by grouping elements with parentheses. For instance, in the first of the following two code samples, the operators will be performed in the default order. In the second code sample, the addition operation will be performed first, because its associated elements are grouped with parentheses, and the multiplication operation will be performed last:
- Accounts[Amount == 2 + 48 * 2]
- Accounts[Amount == (2 + 48) * 2]
Case Sensitivity
Operators are case insensitive. The case sensitivity of values depends on the data source.
Escaping Keywords
If the property name of an object is also a keyword, then you can escape the property name by prefixing it with an @ sign. For instance, in the @Or = 'value' query, we interpret @Or as the property named "Or", not the logical operator OR.