DynamicWhere.ex
DynamicWhere.exv2.1.0·docs

DataType

DataType declares the logical type of a Condition's values. The library uses it to pick the right comparison expression, parse incoming JSON values, and validate that the chosen Operator is legal for that type.

Values

Seven logical types. Each row lists every operator the library will accept when paired with that type — using an unsupported operator throws a validation error.

ValueDescriptionSupported Operators
TextString data.All text operators including the case-insensitive I* variants (IEqual, IContains, IStartsWith, IEndsWith, IIn, etc.), In / NotIn, IsNull / IsNotNull.
GuidGUID stored as a string.Equal, NotEqual, In, NotIn, IsNull, IsNotNull.
NumberAny numeric value — byte through decimal (including short, int, long, float, double).Equal, NotEqual, GreaterThan, GreaterThanOrEqual, LessThan, LessThanOrEqual, Between, NotBetween, In, NotIn, IsNull, IsNotNull.
Booleantrue or false.Equal, NotEqual, IsNull, IsNotNull.
DateTimeFull timestamp (date + time).Equal, NotEqual, GreaterThan, GreaterThanOrEqual, LessThan, LessThanOrEqual, Between, NotBetween, IsNull, IsNotNull.
DateDate-only — compared via the .Date part of the underlying property, so the time component is ignored.Same as DateTime (the comparison strips the time component on both sides).
EnumEnum stored as a string in the database (not as an integer).Equal, NotEqual, Contains, NotContains, StartsWith, EndsWith, NotStartsWith, NotEndsWith, In, NotIn, IsNull, IsNotNull.
Enum storage matters
DataType.Enum assumes enum values are stored as strings. If your EF Core configuration persists enums as integers (the default), filter with DataType.Number instead and send the numeric underlying value.

JSON examples per type

Text

{
  "sort": 1,
  "field": "Name",
  "dataType": "Text",
  "operator": "IContains",
  "values": ["phone"]
}

Guid

{
  "sort": 1,
  "field": "CustomerId",
  "dataType": "Guid",
  "operator": "Equal",
  "values": ["a1b2c3d4-e5f6-7890-abcd-ef1234567890"]
}

Number

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

Boolean

{
  "sort": 1,
  "field": "IsActive",
  "dataType": "Boolean",
  "operator": "Equal",
  "values": [true]
}

DateTime

{
  "sort": 1,
  "field": "CreatedAt",
  "dataType": "DateTime",
  "operator": "Equal",
  "values": ["2024-06-15T14:30:00"]
}

Date

{
  "sort": 1,
  "field": "CreatedAt",
  "dataType": "Date",
  "operator": "GreaterThan",
  "values": ["2024-01-01"]
}

Enum

{
  "sort": 1,
  "field": "Status",
  "dataType": "Enum",
  "operator": "In",
  "values": ["Active", "Pending"]
}

Value coercion

Values is List<object>. Whatever the front-end sends, the library normalizes each element before validating and building the expression.

Incoming runtime typeNormalized form
stringas-is
bool"true" / "false" (lowercase)
JsonElementUnwrapped by ValueKind: string → text, number → raw JSON token, True / False → lowercase string.
numeric / IFormattableInvariantCulture formatting
anything else (e.g. JValue)value.ToString()
nullstring.Empty
Note
Old clients that send ["true"] or ["100"] (quoted strings) keep working unchanged — strings deserialize into the List<object> as string elements and the normalizer passes them through.

C# usage

using DynamicWhere.ex.Enums;

var condition = new Condition
{
    Sort = 1,
    Field = "Price",
    DataType = DataType.Number,
    Operator = Operator.GreaterThan,
    Values = new List<object> { 50 }
};