DynamicWhere.ex
DynamicWhere.exv2.1.0·docs

Operator

Operator declares the comparison applied by a Condition. There are 28 operators total. Every operator that starts with I is the case-insensitive variant — both sides are normalized with .ToLower() before comparison.

Required values at a glance

Each operator expects a specific number of entries in Condition.Values. Sending the wrong count throws a validation error (RequiredOneValue, RequiredTwoValue, RequiredValues, or NotRequiredValues).

Value countOperators
0IsNull, IsNotNull
1All equality, contains, starts-with, ends-with, and ordered comparisons (24 operators total).
2 (exactly)Between, NotBetween
1+In, IIn, NotIn, INotIn

Equality

OperatorDescriptionRequired Values
EqualEquality (case-sensitive for text).1
IEqualEquality (case-insensitive).1
NotEqualInequality (case-sensitive).1
INotEqualInequality (case-insensitive).1

Contains / StartsWith / EndsWith

OperatorDescriptionRequired Values
ContainsText contains (case-sensitive).1
IContainsText contains (case-insensitive).1
NotContainsText does not contain (case-sensitive).1
INotContainsText does not contain (case-insensitive).1
StartsWithStarts with (case-sensitive).1
IStartsWithStarts with (case-insensitive).1
NotStartsWithDoes not start with (case-sensitive).1
INotStartsWithDoes not start with (case-insensitive).1
EndsWithEnds with (case-sensitive).1
IEndsWithEnds with (case-insensitive).1
NotEndsWithDoes not end with (case-sensitive).1
INotEndsWithDoes not end with (case-insensitive).1
Note
Case-insensitive I* operators emit .ToLower() on both sides of the comparison. On SQL Server this is typically free (default collations are case-insensitive). On case-sensitive collations (e.g. PostgreSQL with C locale) this still works but may sidestep an index.

In / NotIn (set membership)

OperatorDescriptionRequired Values
InValue is in the set (case-sensitive for text).1+
IInValue is in the set (case-insensitive).1+
NotInValue is not in the set (case-sensitive).1+
INotInValue is not in the set (case-insensitive).1+

Ordered comparisons & ranges

OperatorDescriptionRequired Values
GreaterThanGreater than.1
GreaterThanOrEqualGreater than or equal.1
LessThanLess than.1
LessThanOrEqualLess than or equal.1
BetweenInclusive range — first value is the lower bound, second is the upper bound.2 (exactly)
NotBetweenOutside the inclusive range defined by the two values.2 (exactly)

Null checks

OperatorDescriptionRequired Values
IsNullProperty is NULL.0
IsNotNullProperty is NOT NULL.0
Warning
Sending any value with IsNull / IsNotNull throws NotRequiredValues. Send an empty array: "values": [].

JSON examples

Range (Between):

{
  "sort": 1,
  "field": "Price",
  "dataType": "Number",
  "operator": "Between",
  "values": [100, 500]
}

Set membership (IIn):

{
  "sort": 1,
  "field": "Country",
  "dataType": "Text",
  "operator": "IIn",
  "values": ["USA", "Canada", "UK"]
}

Null check (IsNull):

{
  "sort": 1,
  "field": "DeletedAt",
  "dataType": "DateTime",
  "operator": "IsNull",
  "values": []
}