Class StructuredQueryEngine
Pure, in-memory semantic reference for every IStructuredStore
query/trim/upsert-comparison operation: filtering, multi-field sorting, distinct-collapsing,
pagination, counting, and the "is this candidate better" write-path policy. Every backend
(key-value shard, HTTP stub, relational provider) delegates to this engine — or reimplements
it identically in its own query language — so query semantics stay identical everywhere.
Inheritance
StructuredQueryEngine
Assembly: Serenity.Global.Domain.dll
Syntax
public static class StructuredQueryEngine
Methods
ApplyFilters(IReadOnlyList<StructuredRecord>, IReadOnlyList<FieldFilter>)
Returns the records matching every filter in filters (ANDed).
Declaration
public static IReadOnlyList<StructuredRecord> ApplyFilters(IReadOnlyList<StructuredRecord> records, IReadOnlyList<FieldFilter> filters)
Parameters
Returns
ApplyOffsetLimit(IReadOnlyList<StructuredRecord>, int, int?)
Skips offset records, then returns at most limit of the rest (unbounded when null).
Declaration
public static IReadOnlyList<StructuredRecord> ApplyOffsetLimit(IReadOnlyList<StructuredRecord> records, int offset, int? limit)
Parameters
Returns
CollapseDistinct(IReadOnlyList<StructuredRecord>, IReadOnlyList<string>)
Collapses sortedRecords (already sorted per the ordering that defines
"best") to the FIRST record encountered per distinct distinctByFields
group.
Declaration
public static IReadOnlyList<StructuredRecord> CollapseDistinct(IReadOnlyList<StructuredRecord> sortedRecords, IReadOnlyList<string> distinctByFields)
Parameters
Returns
Count(IReadOnlyList<StructuredRecord>, IReadOnlyList<FieldFilter>, IReadOnlyList<string>)
Counts records matching filters, collapsed to one per distinctByFields group when non-empty.
Declaration
public static long Count(IReadOnlyList<StructuredRecord> records, IReadOnlyList<FieldFilter> filters, IReadOnlyList<string> distinctByFields)
Parameters
Returns
IsBetter(StructuredValue, StructuredValue, StructuredSortDirection)
Determines whether candidate beats current under
direction — the single write-path "should this submission replace the
stored best?" policy. Strict comparison: an equal value is NOT better.
Declaration
public static bool IsBetter(StructuredValue candidate, StructuredValue current, StructuredSortDirection direction)
Parameters
Returns
Sort(IReadOnlyList<StructuredRecord>, IReadOnlyList<OrderField>)
Declaration
public static IReadOnlyList<StructuredRecord> Sort(IReadOnlyList<StructuredRecord> records, IReadOnlyList<OrderField> ordering)
Parameters
Returns
TrimBeyond(IReadOnlyList<StructuredRecord>, IReadOnlyList<FieldFilter>, IReadOnlyList<OrderField>, int)
Within the records matching scopeFilters, keeps only the best
keepCount — in ordering order — dropping the rest.
Records outside the scope are returned unchanged. A non-positive keepCount is a no-op.
Declaration
public static IReadOnlyList<StructuredRecord> TrimBeyond(IReadOnlyList<StructuredRecord> records, IReadOnlyList<FieldFilter> scopeFilters, IReadOnlyList<OrderField> ordering, int keepCount)
Parameters
Returns