logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    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
    object
    StructuredQueryEngine
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Serenity.Persistence.Domain.Services
    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
    Type Name Description
    IReadOnlyList<StructuredRecord> records
    IReadOnlyList<FieldFilter> filters
    Returns
    Type Description
    IReadOnlyList<StructuredRecord>

    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
    Type Name Description
    IReadOnlyList<StructuredRecord> records
    int offset
    int? limit
    Returns
    Type Description
    IReadOnlyList<StructuredRecord>

    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
    Type Name Description
    IReadOnlyList<StructuredRecord> sortedRecords
    IReadOnlyList<string> distinctByFields
    Returns
    Type Description
    IReadOnlyList<StructuredRecord>

    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
    Type Name Description
    IReadOnlyList<StructuredRecord> records
    IReadOnlyList<FieldFilter> filters
    IReadOnlyList<string> distinctByFields
    Returns
    Type Description
    long

    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
    Type Name Description
    StructuredValue candidate
    StructuredValue current
    StructuredSortDirection direction
    Returns
    Type Description
    bool

    Sort(IReadOnlyList<StructuredRecord>, IReadOnlyList<OrderField>)

    Sorts records by ordering: each successive OrderField breaks ties left by the previous one, compared via Compare(StructuredValue, StructuredValue) and applied in the field's own direction.

    Declaration
    public static IReadOnlyList<StructuredRecord> Sort(IReadOnlyList<StructuredRecord> records, IReadOnlyList<OrderField> ordering)
    Parameters
    Type Name Description
    IReadOnlyList<StructuredRecord> records
    IReadOnlyList<OrderField> ordering
    Returns
    Type Description
    IReadOnlyList<StructuredRecord>

    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
    Type Name Description
    IReadOnlyList<StructuredRecord> records
    IReadOnlyList<FieldFilter> scopeFilters
    IReadOnlyList<OrderField> ordering
    int keepCount
    Returns
    Type Description
    IReadOnlyList<StructuredRecord>
    In this article
    © 2026 Serenity. All Rights Reserved