methodDistinct
public QuerySpec<T, TResult> Distinct()
Creates a new `QuerySpec<T, TResult>` that eliminates duplicate results.
Returns: A new specification with distinct enabled.
methodOrderBy<TKey>
public QuerySpec<T, TResult> OrderBy<TKey>(Expression<Func<T, TKey>> keySelector)
Creates a new `QuerySpec<T, TResult>` with an ascending order applied.
- keySelector: Expression<Func<T, TKey>>
- The key selector.
Returns: A new specification with the ordering applied.
methodOrderByDescending<TKey>
public QuerySpec<T, TResult> OrderByDescending<TKey>(Expression<Func<T, TKey>> keySelector)
Creates a new `QuerySpec<T, TResult>` with a descending order applied.
- keySelector: Expression<Func<T, TKey>>
- The key selector.
Returns: A new specification with the ordering applied.
methodPage
public QuerySpec<T, TResult> Page(int page, int pageSize)
Creates a new `QuerySpec<T, TResult>` with offset-based pagination applied.
- page: int
- The 1-based page number.
- pageSize: int
- The number of records per page. Must be positive.
Returns: A new specification with pagination applied.
methodSearch
public QuerySpec<T, TResult> Search(string searchPhrase, params Expression<Func<T, string?>>[] propertySelectors)
Creates a new `QuerySpec<T, TResult>` with a search filter across one or more string properties using logical OR.
- searchPhrase: string
- The search term to look for.
- propertySelectors: params Expression<Func<T, string?>>[]
- The string property selectors to search within.
Returns: A new specification with the search criteria applied.
methodSeekAfter<TKey>
public QuerySpec<T, TResult> SeekAfter<TKey>(Expression<Func<T, TKey>> keySelector, TKey cursorValue, int take)
Creates a new specification configured for keyset pagination seeking records after the specified cursor.
- keySelector: Expression<Func<T, TKey>>
- The key selector expression.
- cursorValue: TKey
- The cursor value to seek after.
- take: int
- The number of records to return.
Returns: A new specification with the cursor and limit applied.
methodSeekBefore<TKey>
public QuerySpec<T, TResult> SeekBefore<TKey>(Expression<Func<T, TKey>> keySelector, TKey cursorValue, int take)
Creates a new specification configured for keyset pagination seeking records before the specified cursor.
- keySelector: Expression<Func<T, TKey>>
- The key selector expression.
- cursorValue: TKey
- The cursor value to seek before.
- take: int
- The number of records to return.
Returns: A new specification with the cursor and limit applied.
methodSelect
public QuerySpec<T, TResult> Select(Expression<Func<T, TResult>> selector)
Creates a new `QuerySpec<T, TResult>` with the specified projection.
- selector: Expression<Func<T, TResult>>
- The projection expression.
Returns: A new specification with the projection applied.
methodSkip
public QuerySpec<T, TResult> Skip(int count)
Creates a new `QuerySpec<T, TResult>` that skips the first `count` records.
- count: int
- The number of records to skip. Must be non-negative.
Returns: A new specification with the skip count applied.
methodTagWith
public QuerySpec<T, TResult> TagWith(string tag)
Creates a new `QuerySpec<T, TResult>` with the specified diagnostic query tag applied.
- tag: string
- The diagnostic query tag or comment.
Returns: A new specification with the tag applied.
methodTake
public QuerySpec<T, TResult> Take(int count)
Creates a new `QuerySpec<T, TResult>` that returns at most `count` records.
- count: int
- The maximum number of records to return. Must be positive.
Returns: A new specification with the take count applied.
methodThenBy<TKey>
public QuerySpec<T, TResult> ThenBy<TKey>(Expression<Func<T, TKey>> keySelector)
Creates a new `QuerySpec<T, TResult>` with a secondary ascending order applied.
- keySelector: Expression<Func<T, TKey>>
- A function to extract a key from an element.
Returns: A new specification with the secondary ordering applied.
methodThenByDescending<TKey>
public QuerySpec<T, TResult> ThenByDescending<TKey>(Expression<Func<T, TKey>> keySelector)
Creates a new `QuerySpec<T, TResult>` with a secondary descending order applied.
- keySelector: Expression<Func<T, TKey>>
- A function to extract a key from an element.
Returns: A new specification with the secondary descending ordering applied.
methodWhere
public QuerySpec<T, TResult> Where(Expression<Func<T, bool>> predicate)
Creates a new `QuerySpec<T, TResult>` with an additional AND predicate.
- predicate: Expression<Func<T, bool>>
- The predicate to add.
Returns: A new specification with the predicate appended to the criteria.
methodWithCursor<TKey>
public QuerySpec<T, TResult> WithCursor<TKey>(Expression<Func<T, TKey>> keySelector, TKey cursorValue, CursorDirection direction, int take)
Creates a new specification with keyset pagination applied.
- keySelector: Expression<Func<T, TKey>>
- The key selector expression.
- cursorValue: TKey
- The cursor value.
- direction: CursorDirection
- The seek direction.
- take: int
- The maximum number of records to return.
Returns: A new specification with keyset pagination applied.
propertyCriteria
public ImmutableArray<Expression<Func<T, bool>>> Criteria { get; init; }
Gets the filter predicates combined using logical AND.
propertyCursor
public CursorClause<T>? Cursor { get; init; }
Gets the cursor clause for keyset pagination, if configured.
propertyIsDistinct
public bool IsDistinct { get; init; }
Gets a value indicating whether duplicate results should be eliminated.
propertyOrderClauses
public ImmutableArray<IOrderClause<T>> OrderClauses { get; init; }
Gets the ordering clauses applied in sequence.
propertySelector
public Expression<Func<T, TResult>>? Selector { get; init; }
Gets the projection expression from `T` to `TResult`.
propertySkipCount
public int? SkipCount { get; init; }
Gets the number of records to skip for offset-based pagination.
propertyTag
public string? Tag { get; init; }
Gets the diagnostic query tag or comment, if configured.
propertyTakeCount
public int? TakeCount { get; init; }
Gets the maximum number of records to return.
fieldEmpty
public static readonly QuerySpec<T, TResult> Empty
Gets an empty specification with no constraints.