DynamicWhere.ex
DynamicWhere.exv3.4.0·docs

Example 7: Filter — Typed

A Filter bundles a where group, a select list, ordering, and pagination — then flows through Filter<T>, ToList<T>(Filter) or ToListAsync<T>(Filter).

Request

{
  "conditionGroup": {
    "connector": "And",
    "conditions": [
      {
        "sort": 1,
        "field": "Price",
        "dataType": "Number",
        "operator": "GreaterThan",
        "values": ["50"]
      },
      {
        "sort": 2,
        "field": "Category.Name",
        "dataType": "Text",
        "operator": "IEqual",
        "values": ["electronics"]
      }
    ],
    "subConditionGroups": []
  },
  "selects": ["Id", "Name", "Price", "Category.Name"],
  "orders": [
    { "sort": 1, "field": "Price", "direction": "Descending" }
  ],
  "page": {
    "pageNumber": 1,
    "pageSize": 10
  }
}

Response shape (FilterResult<Product>)

{
  "pageNumber": 1,
  "pageSize": 10,
  "pageCount": 5,
  "totalCount": 42,
  "data": [
    {
      "id": 7,
      "name": "Laptop Pro",
      "price": 1299.99,
      "isActive": false,
      "createdAt": "0001-01-01T00:00:00",
      "category": { "id": 5, "name": "Electronics" }
    }
  ],
  "queryString": null
}
Warning
A typed row is a whole Product, not a trimmed object. selects decides which members are read; the rest are still present, holding their defaults. A selected reference navigation also carries its Id when the nested type has one, and a row with no category comes back as an empty category object rather than null. Use FilterDynamic when you want a payload containing only the requested members.
Note
Set getQueryString: true on the extension method to populate queryString with the generated SQL — useful in development.