Skip to content

QueryBuilder1 Class` ​

Definition ​

Immutable, fluent query builder for T.

  • Namespace: JASE.Database
  • Assembly: JASE.Database.dll

Properties ​

NameDescription
FnvHashGets a stable 64-bit hash representing the current query shape.
KeysetRowsReversedGets whether rows from this query are in reverse display order after Before.

Methods ​

NameDescription
QueryBuilder<T> After(KeysetCursor cursor)Applies a forward keyset seek past cursor (next page).
QueryBuilder<T> AllowUnfilteredMutation()Opts into an intentional match-all mutation (WHERE 1=1) when no filters are present.
QueryBuilder<T> AndGroup(Action<GroupBuilder> group)Adds a grouped AND predicate block constructed by GroupBuilder.
QueryBuilder<T> Before(KeysetCursor cursor)Applies a reverse keyset seek before cursor (previous page / seek-last style).
PredicateGroup Build()Materializes the current predicate state into a logical group suitable for SQL generation.
Task<long> Count()Executes a COUNT(*) against the current query.
Task<long> Count(IDatabaseSession connection)Executes a COUNT(*) against the current query.
Task CreateViewAsync(string name, string schema = null)Creates or replaces a database view whose body is this query (must be parameter-free).
Task<int> DeleteAsync(CancellationToken cancellationToken = null)Executes a DELETE for rows matching the current query filters using the bound session.
Task<int> DeleteAsync(IDatabaseSession session, CancellationToken cancellationToken = null)Executes a DELETE for rows matching the current query filters using the specified session.
QueryBuilder<T> Distinct()Marks the query to return only distinct rows.
QueryBuilder<T> EnsureKeysetOrder()Appends the primary key as a final ascending ORDER BY when missing, ensuring a total order for keyset paging.
Task<QueryPlanResult> ExplainAsync(IDatabaseSession session, QueryPlanOptions options = null, CancellationToken cancellationToken = null)Requests an explain / showplan for the current SELECT using the specified session.
Task<QueryPlanResult> ExplainAsync(QueryPlanOptions options = null, CancellationToken cancellationToken = null)Requests an explain / showplan for the current SELECT using the bound session.
Task<T> First()Returns the first row matching the current query.
Task<T> First(IDatabaseSession connection)Returns the first row matching the current query.
QueryBuilder<T> For(TableInfo tableInfo)Creates a QueryBuilder`1 for the specified TableInfo.
QueryBuilder<T> For(TableInfo tableInfo, Expression<Func<T, bool>> filter)Creates a [QueryBuilder`1](/api/database/QueryBuilder_1/) for the specified TableInfo with an initial `WHERE` filter.
QueryBuilder<T> FullJoin(TableInfo target, string alias, string logicalName, string foreignKeyColumn, IEnumerable<string> columns = null, string rootAlias = null)Adds a FULL OUTER JOIN from a foreign-key column on T to target.
KeysetCapability GetKeysetCapability()Conservatively evaluates whether this query can use keyset paging.
int GetLimit()Gets the current LIMIT value, if any.
Task<List<T>> GetList()Executes the query and materializes all matching rows into a list.
Task<List<T>> GetList(IDatabaseSession connection)Executes the query and materializes all matching rows into a list.
IAsyncEnumerable<T> GetListStream(CancellationToken cancellationToken = null)Executes the query and returns a lazy async stream of rows.
IAsyncEnumerable<T> GetListStream(IDatabaseSession connection, CancellationToken cancellationToken = null)Executes the query and returns a lazy async stream of rows.
int GetOffset()Gets the current OFFSET value, if any.
IReadOnlyList<OrderBy> GetOrderBy()Gets a copy of the current ORDER BY list (display order, unless Before / SeekLast inverted it).
QueryBuilder<T> InnerJoin(TableInfo target, string alias, string logicalName, string foreignKeyColumn, IEnumerable<string> columns = null, string rootAlias = null)Adds an INNER JOIN from a foreign-key column on T to target.
QueryBuilder<T> Join(IJoin join, string rootAlias = null)Adds a pre-built join definition. Call multiple times to append multiple joins.
QueryBuilder<T> Join(JoinType joinType, TableInfo target, string alias, string logicalName, string foreignKeyColumn, IEnumerable<string> columns = null, string rootAlias = null)Adds a foreign-key join of the requested joinType. Call multiple times to append multiple joins (order is preserved in SQL).
QueryBuilder<T> LeftJoin(TableInfo target, string alias, string logicalName, string foreignKeyColumn, IEnumerable<string> columns = null, string rootAlias = null)Adds a LEFT OUTER JOIN from a foreign-key column on T to target.
QueryBuilder<T> LeftJoinRelated(string alias, IEnumerable<string> columns = null, string rootAlias = null)Adds a LEFT OUTER JOIN for a RelatedAttribute navigation of type TRelated.
QueryBuilder<T> Limit(int? limit, int? offset = null)Applies a LIMIT (and optional OFFSET) to the query.
QueryBuilder<T> OrderBy(Expression<Func<T, TProp>> selector)Adds an ascending ORDER BY using a mapped property.
QueryBuilder<T> OrderBy(string column)Adds an ascending ORDER BY using a column name.
QueryBuilder<T> OrderByDescending(Expression<Func<T, TProp>> selector)Adds a descending ORDER BY using a mapped property.
QueryBuilder<T> OrderByDescending(string column)Adds a descending ORDER BY using a column name.
QueryBuilder<T> OrGroup(Action<GroupBuilder> group)Adds a grouped OR predicate block constructed by GroupBuilder.
QueryBuilder<T> RightJoin(TableInfo target, string alias, string logicalName, string foreignKeyColumn, IEnumerable<string> columns = null, string rootAlias = null)Adds a RIGHT OUTER JOIN from a foreign-key column on T to target.
QueryBuilder<T> SeekLast()Anchors the query at the last display page: invert ORDER BY (and NULL placement) with no seek predicate.
QueryBuilder<T> Select(Expression<Func<T, TProj>> selector)Restricts the query to the projected columns from selector.
QueryBuilder<T> Select(IEnumerable<string> columns)Restricts the query to the specified columns.
QueryBuilder<T> Select(string[] columns)Restricts the query to the specified columns.
UpdateSetBuilder<T> Set(Expression<Func<T, T>> initializer)Begins an UPDATE SET clause using an initializer expression.
UpdateSetBuilder<T> Set(Expression<Func<T, TProp>> selector, TProp value)Begins an UPDATE SET clause by assigning a value to a mapped property.
UpdateSetBuilder<T> Set(ValueTuple<Expression<Func<T, TProp>>, TProp>[] sets)Begins an UPDATE SET clause by assigning multiple values.
QueryBuilder<T> ThenBy(Expression<Func<T, TProp>> selector)Adds a secondary ascending ORDER BY using a mapped property.
QueryBuilder<T> ThenBy(string column)Adds an additional ascending ORDER BY using a column name.
QueryBuilder<T> ThenByDescending(Expression<Func<T, TProp>> selector)Adds an additional descending ORDER BY using a mapped property.
QueryBuilder<T> ThenByDescending(string column)Adds a secondary descending ORDER BY using a column name.
DeleteStatement ToDeleteSql(IConnection connection)Builds a DELETE statement for the current query using the connection's generator.
DeleteStatement ToDeleteSql(ISqlGenerator generator)Builds a DELETE statement for the current query using the specified SQL generator.
SelectStatement ToSql()Builds a SELECT statement for the current query using the connection's generator.
SelectStatement ToSql(IConnection connection)Builds a SELECT statement for the current query using the connection's generator.
SelectStatement ToSql(ISqlGenerator generator)Builds a SELECT statement for the current query using the provided generator.
QueryBuilder<T> Where(Expression<Func<T, TProp>> selector, PredicateOperator op, object value)Adds a simple comparison filter for a single mapped property.
QueryBuilder<T> Where(Expression<Func<T, bool>> filter)Adds a boolean filter to the query using a C# lambda over T.
QueryBuilder<T> Where(IPredicateNode node)Adds a pre-built predicate node with AND logic.
QueryBuilder<T> Where(string column, PredicateOperator op, object value)Adds a comparison filter using a raw column name.

Remarks ​

This type is copy-on-write: each method that changes the query returns a new QueryBuilder`1 instance. Reuse baseline queries safely across async flows or different code paths.