Fluent C# builder
var request = new ServiceQueryRequestBuilder()
.Contains("Name", "Ann")
.Or()
.Contains("Name", "Ben")
.SortDesc("CreatedAt")
.Paging(1, 25, true)
.Select("Name", "Status")
.Build();

Query operations reference
Reference the operations, aliases, request shapes, and type guidance available through ServiceQuery®.
Flexible queries. Deliberate boundaries.
One request model
ServiceQuery® gives clients a structured way to express useful query combinations. The API still owns field policy, authorization, limits, provider selection, and execution.
Read returned records, optional count metadata, and aggregate results.
View the responseCompose comparisons, text operations, ranges, null checks, and sets.
View filteringOrder results with ascending or descending query operations.
View sortingControl page number, page size, and optional total-count metadata.
View pagingRequest count, sums, averages, minimums, and maximums where supported.
View aggregatesResponse
ServiceQueryResponse<T> returns the records from the query and exposes optional metadata when the request asks for it.
| Property | Type | When it is populated | Meaning |
|---|---|---|---|
List | List<T> | Always initialized | The records returned by the executed query. |
Count | int? | When IncludeCount() or the equivalent request option is used | The total record count for the query. |
Aggregate | double? | When an aggregate filter is included | The aggregate result returned by the query. |
Filtering
The fluent builder and JSON request use the same underlying filter vocabulary. Use the aliases when constructing requests manually.
| Category | Operation | Builder method | Filter type | Alias | Type guidance |
|---|---|---|---|---|---|
| Grouping | Begin | BeginExpression() or Begin() | begin | ( | Optional; use with complex predicates. |
| Grouping | End | EndExpression() or End() | end | ) | Optional; use with complex predicates. |
| Grouping | And | And() | and | & | Required when combining multiple comparison filters. |
| Grouping | Or | Or() | or | | | Required when combining multiple comparison filters. |
| Comparison | Equal | IsEqual(property, value) | equal | eq, = | String, numeric, date/time, Boolean, and nullable columns. |
| Comparison | Not equal | IsNotEqual(property, value) | notequal | != | String, numeric, date/time, Boolean, and nullable columns. |
| Comparison | Greater than | IsGreaterThan(property, value) | greaterthan | gt, > | Numeric and date/time values, with nullable columns supported where the underlying comparison is valid. |
| Comparison | Greater than or equal | IsGreaterThanOrEqual(property, value) | greaterthanorequal | greaterthanequal, gtoe, gte, >= | Numeric and date/time values, with nullable columns supported where the underlying comparison is valid. |
| Comparison | Less than | IsLessThan(property, value) | lessthan | lt, < | Numeric and date/time values, with nullable columns supported where the underlying comparison is valid. |
| Comparison | Less than or equal | IsLessThanOrEqual(property, value) | lessthanorequal | lessthanequal, ltoe, lte, <= | Numeric and date/time values, with nullable columns supported where the underlying comparison is valid. |
| Comparison | Between | Between(property, low, high) | between | None | Numeric and date/time values. A null value is not a range operand. |
| Text | Contains | Contains(property, value) | contains | None | String values. |
| Text | Starts with | StartsWith(property, value) | startswith | sw | String values. |
| Text | Ends with | EndsWith(property, value) | endswith | ew | String values. |
| Null | Is null | IsNull(property) or Null(property, true) | isnull | null | Reference and nullable columns. |
| Null | Is not null | IsNotNull(property) or Null(property, false) | isnotnull | notnull, !null | Reference and nullable columns. |
| Set | In set | IsInSet(property, values) or Set(property, true, values) | inset | set | String, numeric, date/time, Boolean, and other supported scalar values. |
| Set | Not in set | IsNotInSet(property, values) or Set(property, false, values) | notinset | notset, !set | String, numeric, date/time, Boolean, and other supported scalar values. |
Sorting
Use the fluent builder for typed application code or the filter aliases when constructing a request directly.
| Category | Operation | Builder method | Filter type | Alias | Type guidance |
|---|---|---|---|---|---|
| Sorting | Ascending | SortAsc(property) or Sort(property, true) | sortasc | sa, orderasc, oa | String, numeric, date/time, Boolean, and nullable columns. |
| Sorting | Descending | SortDesc(property) or Sort(property, false) | sortdesc | sd, orderdesc, od | String, numeric, date/time, Boolean, and nullable columns. |
Paging
Paging is expressed as request metadata rather than a property-specific filter.
| Category | Operation | Builder method | Filter type | Alias | Value |
|---|---|---|---|---|---|
| Paging | Page number | Paging(pageNumber, pageSize, includeCount) | pagenumber | pagenum, pn | Integer page number. |
| Paging | Page size | Paging(pageNumber, pageSize, includeCount) | pagesize | ps | Integer result limit. |
| Paging | Include count | Paging(pageNumber, pageSize, includeCount) | includecount | ic | Boolean response-count request. |
| Paging | Include count separately | IncludeCount() | includecount | ic | Requests total-count metadata. |
Aggregates
Aggregate behavior depends on the value type and provider expression support. Numeric nullable columns remain valid for the supported numeric aggregates.
| Category | Operation | Builder method | Filter type | Alias | Type guidance |
|---|---|---|---|---|---|
| Aggregate | Count | Count() | count | None | Counts the query result; no property is required. |
| Aggregate | Sum | Sum(property) | sum | None | Numeric and nullable numeric columns. |
| Aggregate | Average | Average(property) | average | avg | Numeric and nullable numeric columns. |
| Aggregate | Minimum | Minimum(property) | minimum | min | Ordered values such as numeric, string, date/time, and nullable columns where supported. |
| Aggregate | Maximum | Maximum(property) | maximum | max | Ordered values such as numeric, string, date/time, and nullable columns where supported. |
Result shaping
Selection and distinctness change the result shape. They are separate from filtering, sorting, paging, and aggregation.
| Category | Operation | Builder method | Filter type | Alias | Value |
|---|---|---|---|---|---|
| Result shaping | Select properties | Select(params string[] propertyNames) | select | sel | One or more property names allowed by the API. |
| Result shaping | Distinct results | Distinct() | distinct | None | Requests distinct result behavior for the supported query shape. |
Type and provider guidance
These type families describe the normal query surface. Provider translation, API field policy, authorization, limits, and data classification remain separate boundaries.
| Value family | Filtering | Sorting | Aggregates | Notes |
|---|---|---|---|---|
| String | Equality, text, sets | Ascending and descending | Minimum and maximum where supported | Contains, StartsWith, and EndsWith are string operations. |
| Numeric | Comparison, Between, sets | Ascending and descending | Count, Sum, Average, Minimum, Maximum | Numeric ranges and aggregates remain provider-sensitive. |
| Date/time | Comparison, Between, sets | Ascending and descending | Minimum and maximum where supported | Between uses lower and upper date/time values. |
| Boolean | Equality and supported sets | Provider-supported ordering | Not a numeric aggregate target | Use explicit API policy when exposing Boolean fields. |
| Nullable columns | Underlying operations plus explicit null checks | Supported | Supported for the applicable aggregate | Null is not a Between operand. Use IsNull or IsNotNull for null semantics. |
Provider compatibility is not identical behavior across every source. Verify the relevant expression, policy, and provider path for the API you own.
Same intent in code and JSON
The API remains responsible for validating fields, applying authorization scope, enforcing limits, and selecting the queryable source.
var request = new ServiceQueryRequestBuilder()
.Contains("Name", "Ann")
.Or()
.Contains("Name", "Ben")
.SortDesc("CreatedAt")
.Paging(1, 25, true)
.Select("Name", "Status")
.Build();
{
"filters": [
{ "filterType": "contains", "properties": ["Name"], "values": ["Ann"] },
{ "filterType": "or" },
{ "filterType": "contains", "properties": ["Name"], "values": ["Ben"] },
{ "filterType": "sortdesc", "properties": ["CreatedAt"] },
{ "filterType": "pagenumber", "values": ["1"] },
{ "filterType": "pagesize", "values": ["25"] },
{ "filterType": "includecount", "values": ["true"] },
{ "filterType": "select", "properties": ["Name", "Status"] }
]
}
Inspect. Run. Adopt.
Review the request model, run the bounded demo, and decide where structured query power belongs in the API you already own.