Class EntityBuilder<TEntity>
Fluent, immutable query builder over a mapped entity type; created by
IDataContext.From<TEntity>().
public class EntityBuilder<TEntity> : ICloneable
Type Parameters
TEntityThe mapped entity type the query projects.
- Inheritance
-
EntityBuilder<TEntity>
- Implements
- Derived
-
JoinedEntityBuilder<T1, T2>
- Inherited Members
- Extension Methods
Constructors
EntityBuilder()
Initializes an unbound builder: a context-independent composition of a runtime source
descriptor. The chain carries no data context on purpose — no placeholder context is ever
constructed — so every context-dependent operation fails explicitly through
RequireContext until the source is consumed by
IDataContext.From(Expression<Func<EntityBuilder<T>>>).
protected EntityBuilder()
EntityBuilder(IDataContext)
Initializes a builder over the mapped entity type; the source is resolved from entity metadata.
public EntityBuilder(IDataContext dataProvider)
Parameters
dataProviderIDataContextThe data context that creates the query command.
EntityBuilder(IDataContext, QueryCommand<TEntity>)
Initializes a builder whose source is the derived query.
public EntityBuilder(IDataContext dataProvider, QueryCommand<TEntity> query)
Parameters
dataProviderIDataContextThe data context that creates the query command.
queryQueryCommand<TEntity>The derived query to select from.
EntityBuilder(IDataContext, string)
Initializes a builder over the raw table named table.
public EntityBuilder(IDataContext dataProvider, string table)
Parameters
dataProviderIDataContextThe data context that creates the query command.
tablestringThe physical table name to select from.
Exceptions
- ArgumentNullException
tableis null.- ArgumentException
tableis empty or consists only of white-space characters.
Fields
Paging
The limit/offset paging state set by Limit, Offset and Page.
public Paging Paging
Field Value
_dataProvider
The data context this builder creates commands from and resolves sources against, or null
when the builder composes an unbound, context-independent source (a runtime TVF descriptor).
Context-dependent operations must go through RequireContext, never this field.
protected readonly IDataContext? _dataProvider
Field Value
_joins
The join clauses collected so far, or null when the query has no joins.
protected List<JoinExpression>? _joins
Field Value
Properties
Joins
The join clauses applied to the query, or null when there are none.
public List<JoinExpression>? Joins { get; set; }
Property Value
RequireContext
The data context this builder is bound to. On an unbound source chain the operation is rejected with InvalidOperationException instead of executing against entity metadata or dereferencing a missing context.
protected IDataContext RequireContext { get; }
Property Value
Exceptions
- InvalidOperationException
The builder composes an unbound source.
Sorting
The ordering keys applied by OrderBy/OrderByDescending, or null when the
query is unordered.
public List<Sorting>? Sorting { get; set; }
Property Value
Methods
AliasRoot<TNext, TNextEntity>(Func<IDataContext, TNext>)
Root-alias seam (issue #160, Phase 2): re-roots a plain source builder into a caller-created
builder whose projection shape names the root slot 1 lexically (for example
AliasProjection_A1_Order<Order>), preserving the source's query state (physical table
or derived source, CTE declarations, overrides, source options and hints). The generated
.WithAlias(Alias.X) extension supplies create. It is root-only: a
builder that already carries a join, JoinInto or a projection shape is rejected, and the
in-memory provider fails closed because it cannot project named aliases.
public TNext AliasRoot<TNext, TNextEntity>(Func<IDataContext, TNext> create) where TNext : EntityBuilder<TNextEntity>
Parameters
createFunc<IDataContext, TNext>Creates an empty
TNextbound to this builder's data context.
Returns
- TNext
A new
TNextcarrying this builder's source state and no joins.
Type Parameters
TNextThe generated builder type that receives the root alias.
TNextEntityThe root-alias projection type
TNextis built over.
Exceptions
- ArgumentNullException
createis null.- NotSupportedException
The in-memory provider cannot project named aliases, or the receiver is not the root source.
As<TResult>(Expression<Func<TEntity, TResult>>)
Projects each row with selector and exposes the result as a derived table,
returning a builder that can be joined, filtered and projected further. This names an
intermediate join projection (typically p => new { p.Item1.X, p.Item2.Y }) and starts a
new join from it, so the fixed Projection<T1..T8> arity cap no longer terminates the
chain: ...Join(...).As(p => new { ... }).Join(...) works on every arity.
public EntityBuilder<TResult> As<TResult>(Expression<Func<TEntity, TResult>> selector)
Parameters
selectorExpression<Func<TEntity, TResult>>The projection expression, for example
p => new { p.Item1.Id, p.Item2.Name }.
Returns
- EntityBuilder<TResult>
A builder over the derived table that can be composed further.
Type Parameters
TResultThe named projection type produced by
selector.
Remarks
Implemented as DataProvider.From(Select(selector)): only the projected members stay
visible to later joins, and the projection becomes a materialization boundary, so outer-join
semantics across the boundary follow derived-table rules. A subsequent Join on the
in-memory provider throws NotSupportedException (derived sources cannot be joined
in memory).
Exceptions
- NotSupportedException
A following
Join/Applyon the derived source is rejected by the in-memory provider.
Asc(Expression<Func<TEntity, object?>>)
Ascending ORDER BY key of a named window declared with Window(string, Expression<Func<TEntity, object?>>[]?, NamedWindowOrderKey[]?, WindowFrame?).
public NamedWindowOrderKey Asc(Expression<Func<TEntity, object?>> expression)
Parameters
expressionExpression<Func<TEntity, object>>
Returns
Clone()
Returns a copy of this builder. Because the modifier methods already return copies, this is useful to fork a query without applying a modifier.
public EntityBuilder<TEntity> Clone()
Returns
- EntityBuilder<TEntity>
A new builder with the same state.
CloneImp()
Creates the copy returned by Clone() and the explicit ICloneable.Clone call.
Overridden by derived builders to clone their extra state.
protected virtual object CloneImp()
Returns
- object
A new builder with the same state.
CopyTo(EntityBuilder<TEntity>)
Copies this builder's state onto dst; called by CloneImp().
Protected so derived builders can extend the copy with their own state.
protected virtual void CopyTo(EntityBuilder<TEntity> dst)
Parameters
dstEntityBuilder<TEntity>The builder that receives the state.
Remarks
Collections that no writer ever mutates in place are shared with the copy rather than duplicated:
_loadSpecs and _joinIntos are always replaced wholesale by LoadWith/JoinInto,
and _windows is appended to only through Window, which detaches the shared list
before its first write. _arrayJoins and _joins stay
copied because provider extensions (ClickHouse ArrayJoin/semi-anti join) append to them in
place after a clone; the copy keeps those writes off the parent and its sibling branches.
CrossApply(string, Action<JoinOptions>?)
Adds a CROSS APPLY over the table named table without an explicit source.
public JoinedEntityBuilder<TEntity, TableAlias> CrossApply(string table, Action<JoinOptions>? options = null)
Parameters
tablestringThe physical table name of the joined source.
optionsAction<JoinOptions>Optional per-join configuration; forwarded unchanged.
Returns
- JoinedEntityBuilder<TEntity, TableAlias>
A builder over the projection extended with TableAlias.
Remarks
A null, empty, or whitespace-only table is rejected at the call site with ArgumentNullException / ArgumentException (ParamName == "table"), matching the explicit ctx.From(table) form.
CrossApply<TJoinEntity>(Cte<TJoinEntity>)
Applies the typed CTE cte with CROSS APPLY.
public JoinedEntityBuilder<TEntity, TJoinEntity> CrossApply<TJoinEntity>(Cte<TJoinEntity> cte)
Parameters
cteCte<TJoinEntity>The CTE descriptor, converted with this builder's context.
Returns
- JoinedEntityBuilder<TEntity, TJoinEntity>
A builder over the applied projection.
Type Parameters
TJoinEntityThe CTE's projection type.
Exceptions
- ArgumentNullException
cteis null.
CrossApply<TJoinEntity>(Cte<TJoinEntity>, Action<JoinOptions>?)
Applies the typed CTE cte with CROSS APPLY and per-join options.
public JoinedEntityBuilder<TEntity, TJoinEntity> CrossApply<TJoinEntity>(Cte<TJoinEntity> cte, Action<JoinOptions>? options)
Parameters
cteCte<TJoinEntity>The CTE descriptor, converted with this builder's context.
optionsAction<JoinOptions>Per-join configuration.
Returns
- JoinedEntityBuilder<TEntity, TJoinEntity>
A builder over the applied projection.
Type Parameters
TJoinEntityThe CTE's projection type.
Exceptions
- ArgumentNullException
cteis null.
CrossApply<TJoinEntity>(EntityBuilder<TJoinEntity>, Action<JoinOptions>?)
Applies _ to every left-hand row (CROSS APPLY / CROSS JOIN LATERAL).
There is no ON condition.
public JoinedEntityBuilder<TEntity, TJoinEntity> CrossApply<TJoinEntity>(EntityBuilder<TJoinEntity> _, Action<JoinOptions>? options = null)
Parameters
_EntityBuilder<TJoinEntity>The builder for the applied entity; only its source is used.
optionsAction<JoinOptions>Optional per-join configuration; an APPLY rejects strictness/GLOBAL/table hints at render time but folds a join hint into the statement-level hint comment on inline-hint dialects.
Returns
- JoinedEntityBuilder<TEntity, TJoinEntity>
A builder over the applied projection.
Type Parameters
TJoinEntity
CrossApply<TJoinEntity>(QueryCommand<TJoinEntity>, Action<JoinOptions>?)
Applies a derived query to every left-hand row (CROSS APPLY).
public JoinedEntityBuilder<TEntity, TJoinEntity> CrossApply<TJoinEntity>(QueryCommand<TJoinEntity> query, Action<JoinOptions>? options = null)
Parameters
queryQueryCommand<TJoinEntity>optionsAction<JoinOptions>
Returns
- JoinedEntityBuilder<TEntity, TJoinEntity>
Type Parameters
TJoinEntity
CrossApply<TJoinEntity>(Action<JoinOptions>?)
Adds a CROSS APPLY over TJoinEntity without an explicit source; TJoinEntity is resolved through this builder's context (From<TJoinEntity>()) and forwarded to the source-explicit overload.
public JoinedEntityBuilder<TEntity, TJoinEntity> CrossApply<TJoinEntity>(Action<JoinOptions>? options = null)
Parameters
optionsAction<JoinOptions>Optional per-join configuration; forwarded unchanged to the source-explicit overload.
Returns
- JoinedEntityBuilder<TEntity, TJoinEntity>
A builder over the projection extended with
TJoinEntity.
Type Parameters
TJoinEntityThe entity type of the joined table.
CrossApply<TJoinEntity>(Expression<Func<TEntity, EntityBuilder<TJoinEntity>>>, Action<JoinOptions>?)
Applies a correlated derived query to every left-hand row (CROSS APPLY /
CROSS JOIN LATERAL). source receives the left-hand row, so the query
it builds may reference its columns; there is no ON condition.
public JoinedEntityBuilder<TEntity, TJoinEntity> CrossApply<TJoinEntity>(Expression<Func<TEntity, EntityBuilder<TJoinEntity>>> source, Action<JoinOptions>? options = null)
Parameters
sourceExpression<Func<TEntity, EntityBuilder<TJoinEntity>>>optionsAction<JoinOptions>
Returns
- JoinedEntityBuilder<TEntity, TJoinEntity>
Type Parameters
TJoinEntity
CrossApply<TJoinEntity>(Expression<Func<TEntity, QueryCommand<TJoinEntity>>>, Action<JoinOptions>?)
Applies a correlated derived query to every left-hand row (CROSS APPLY /
CROSS JOIN LATERAL). source receives the left-hand row, so the query
it builds may reference its columns; there is no ON condition.
public JoinedEntityBuilder<TEntity, TJoinEntity> CrossApply<TJoinEntity>(Expression<Func<TEntity, QueryCommand<TJoinEntity>>> source, Action<JoinOptions>? options = null)
Parameters
sourceExpression<Func<TEntity, QueryCommand<TJoinEntity>>>optionsAction<JoinOptions>
Returns
- JoinedEntityBuilder<TEntity, TJoinEntity>
Type Parameters
TJoinEntity
CrossJoin(string, Action<JoinOptions>?)
Adds a CROSS JOIN over the table named table without an explicit source.
public JoinedEntityBuilder<TEntity, TableAlias> CrossJoin(string table, Action<JoinOptions>? options = null)
Parameters
tablestringThe physical table name of the joined source.
optionsAction<JoinOptions>Optional per-join configuration; forwarded unchanged.
Returns
- JoinedEntityBuilder<TEntity, TableAlias>
A builder over the projection extended with TableAlias.
Remarks
A null, empty, or whitespace-only table is rejected at the call site with ArgumentNullException / ArgumentException (ParamName == "table"), matching the explicit ctx.From(table) form.
CrossJoin<TJoinEntity>(Cte<TJoinEntity>)
Adds a cross join over the typed CTE cte.
public JoinedEntityBuilder<TEntity, TJoinEntity> CrossJoin<TJoinEntity>(Cte<TJoinEntity> cte)
Parameters
cteCte<TJoinEntity>The CTE descriptor, converted with this builder's context.
Returns
- JoinedEntityBuilder<TEntity, TJoinEntity>
A builder over the joined projection.
Type Parameters
TJoinEntityThe CTE's projection type.
Exceptions
- ArgumentNullException
cteis null.
CrossJoin<TJoinEntity>(Cte<TJoinEntity>, Action<JoinOptions>?)
Adds a cross join over the typed CTE cte with per-join options.
public JoinedEntityBuilder<TEntity, TJoinEntity> CrossJoin<TJoinEntity>(Cte<TJoinEntity> cte, Action<JoinOptions>? options)
Parameters
cteCte<TJoinEntity>The CTE descriptor, converted with this builder's context.
optionsAction<JoinOptions>Per-join configuration.
Returns
- JoinedEntityBuilder<TEntity, TJoinEntity>
A builder over the joined projection.
Type Parameters
TJoinEntityThe CTE's projection type.
Exceptions
- ArgumentNullException
cteis null.
CrossJoin<TJoinEntity>(EntityBuilder<TJoinEntity>, Action<JoinOptions>?)
Adds a cross join producing the Cartesian product of the two sources; there is no ON
condition.
public JoinedEntityBuilder<TEntity, TJoinEntity> CrossJoin<TJoinEntity>(EntityBuilder<TJoinEntity> _, Action<JoinOptions>? options = null)
Parameters
_EntityBuilder<TJoinEntity>The builder for the joined entity; only its source is used.
optionsAction<JoinOptions>Optional per-join configuration, for example
j => j.WithJoinHint("loop"). A cross join rejects every modifier at render time.
Returns
- JoinedEntityBuilder<TEntity, TJoinEntity>
A builder over the joined projection.
Type Parameters
TJoinEntity
CrossJoin<TJoinEntity>(QueryCommand<TJoinEntity>, Action<JoinOptions>?)
Adds a cross join to the derived query, producing the Cartesian product of
the two sources; there is no ON condition.
public JoinedEntityBuilder<TEntity, TJoinEntity> CrossJoin<TJoinEntity>(QueryCommand<TJoinEntity> query, Action<JoinOptions>? options = null)
Parameters
queryQueryCommand<TJoinEntity>The derived query to join.
optionsAction<JoinOptions>Optional per-join configuration; a cross join rejects every modifier at render time.
Returns
- JoinedEntityBuilder<TEntity, TJoinEntity>
A builder over the joined projection.
Type Parameters
TJoinEntity
CrossJoin<TJoinEntity>(Action<JoinOptions>?)
Adds a CROSS JOIN over TJoinEntity without an explicit source; TJoinEntity is resolved through this builder's context (From<TJoinEntity>()) and forwarded to the source-explicit overload.
public JoinedEntityBuilder<TEntity, TJoinEntity> CrossJoin<TJoinEntity>(Action<JoinOptions>? options = null)
Parameters
optionsAction<JoinOptions>Optional per-join configuration; forwarded unchanged to the source-explicit overload.
Returns
- JoinedEntityBuilder<TEntity, TJoinEntity>
A builder over the projection extended with
TJoinEntity.
Type Parameters
TJoinEntityThe entity type of the joined table.
Desc(Expression<Func<TEntity, object?>>)
Descending ORDER BY key of a named window declared with Window(string, Expression<Func<TEntity, object?>>[]?, NamedWindowOrderKey[]?, WindowFrame?).
public NamedWindowOrderKey Desc(Expression<Func<TEntity, object?>> expression)
Parameters
expressionExpression<Func<TEntity, object>>
Returns
Distinct()
Adds SELECT DISTINCT, removing duplicate result rows. Cannot be combined with
DistinctOn.
public EntityBuilder<TEntity> Distinct()
Returns
- EntityBuilder<TEntity>
A builder with the DISTINCT modifier.
ForShare()
Locks the selected rows in shared mode until the transaction ends, blocking while a locked row is held
by another transaction. Renders a trailing FOR SHARE clause on dialects that support it, or a
table hint on the primary source (with (holdlock) on SQL Server). Requires a dialect that
supports row locking (see Lock).
public EntityBuilder<TEntity> ForShare()
Returns
- EntityBuilder<TEntity>
ForShare(LockWaitMode)
Locks the selected rows in shared mode until the transaction ends, with the requested wait behaviour
for rows already locked by another transaction. Renders a trailing FOR SHARE [NOWAIT | SKIP LOCKED]
clause on dialects that support it, or the matching table hint on the primary source
(with (holdlock, nowait)/with (holdlock, readpast) on SQL Server). Requires a dialect that
supports row locking (see Lock).
public EntityBuilder<TEntity> ForShare(LockWaitMode wait)
Parameters
waitLockWaitModeHow to react to a row already locked by another transaction.
Returns
- EntityBuilder<TEntity>
ForSystemTime(TemporalClause)
Adds a FOR SYSTEM_TIME clause to the primary table, querying a system-versioned (temporal)
table as of a point in time or over a range. Requires a dialect that supports it (see
SupportsTemporalTable).
public EntityBuilder<TEntity> ForSystemTime(TemporalClause clause)
Parameters
clauseTemporalClauseThe temporal clause, built with the NextORM.Core.EntityBuilder<TEntity>.TemporalClause factory methods.
Returns
- EntityBuilder<TEntity>
ForUpdate()
Locks the selected rows exclusively until the transaction ends, blocking while a locked row is held
by another transaction. Renders a trailing FOR UPDATE clause on dialects that support it, or a
table hint on the primary source (with (updlock) on SQL Server). Requires a dialect that
supports row locking (see Lock).
public EntityBuilder<TEntity> ForUpdate()
Returns
- EntityBuilder<TEntity>
ForUpdate(LockWaitMode)
Locks the selected rows exclusively until the transaction ends, with the requested wait behaviour for
rows already locked by another transaction. Renders a trailing FOR UPDATE [NOWAIT | SKIP LOCKED]
clause on dialects that support it, or the matching table hint on the primary source
(with (updlock, nowait)/with (updlock, readpast) on SQL Server). Requires a dialect that
supports row locking (see Lock).
public EntityBuilder<TEntity> ForUpdate(LockWaitMode wait)
Parameters
waitLockWaitModeHow to react to a row already locked by another transaction.
Returns
- EntityBuilder<TEntity>
FullJoin(string, Expression<Func<TEntity, TableAlias, bool>>, Action<JoinOptions>?)
Adds a FULL JOIN over the table named table without an explicit source.
public JoinedEntityBuilder<TEntity, TableAlias> FullJoin(string table, Expression<Func<TEntity, TableAlias, bool>> joinCondition, Action<JoinOptions>? options = null)
Parameters
tablestringThe physical table name of the joined source.
joinConditionExpression<Func<TEntity, TableAlias, bool>>A predicate relating the current entity to the joined TableAlias row.
optionsAction<JoinOptions>Optional per-join configuration; forwarded unchanged.
Returns
- JoinedEntityBuilder<TEntity, TableAlias>
A builder over the projection extended with TableAlias.
Remarks
A null joinCondition is accepted and renders no ON clause, matching the explicit form over ctx.From(table).
FullJoin<TJoinEntity>(Cte<TJoinEntity>, Expression<Func<TEntity, TJoinEntity, bool>>)
Adds a full outer join over the typed CTE cte.
public JoinedEntityBuilder<TEntity, TJoinEntity> FullJoin<TJoinEntity>(Cte<TJoinEntity> cte, Expression<Func<TEntity, TJoinEntity, bool>> joinCondition)
Parameters
cteCte<TJoinEntity>The CTE descriptor, converted with this builder's context.
joinConditionExpression<Func<TEntity, TJoinEntity, bool>>The join predicate over the two entities.
Returns
- JoinedEntityBuilder<TEntity, TJoinEntity>
A builder over the joined projection.
Type Parameters
TJoinEntityThe CTE's projection type.
Exceptions
- ArgumentNullException
cteorjoinConditionis null.
FullJoin<TJoinEntity>(Cte<TJoinEntity>, Expression<Func<TEntity, TJoinEntity, bool>>, Action<JoinOptions>?)
Adds a full outer join over the typed CTE cte with per-join options.
public JoinedEntityBuilder<TEntity, TJoinEntity> FullJoin<TJoinEntity>(Cte<TJoinEntity> cte, Expression<Func<TEntity, TJoinEntity, bool>> joinCondition, Action<JoinOptions>? options)
Parameters
cteCte<TJoinEntity>The CTE descriptor, converted with this builder's context.
joinConditionExpression<Func<TEntity, TJoinEntity, bool>>The join predicate over the two entities.
optionsAction<JoinOptions>Per-join configuration.
Returns
- JoinedEntityBuilder<TEntity, TJoinEntity>
A builder over the joined projection.
Type Parameters
TJoinEntityThe CTE's projection type.
Exceptions
- ArgumentNullException
cteorjoinConditionis null.
FullJoin<TJoinEntity>(EntityBuilder<TJoinEntity>, Expression<Func<TEntity, TJoinEntity, bool>>, Action<JoinOptions>?)
Adds a full outer join: unmatched rows from both sides are kept, with the other side's columns
set to NULL.
public JoinedEntityBuilder<TEntity, TJoinEntity> FullJoin<TJoinEntity>(EntityBuilder<TJoinEntity> _, Expression<Func<TEntity, TJoinEntity, bool>> joinCondition, Action<JoinOptions>? options = null)
Parameters
_EntityBuilder<TJoinEntity>The builder for the joined entity; only its source is used.
joinConditionExpression<Func<TEntity, TJoinEntity, bool>>The join predicate over the two entities.
optionsAction<JoinOptions>Optional per-join configuration, for example
j => j.Global()orj => j.WithStrictness(JoinStrictness.Any).
Returns
- JoinedEntityBuilder<TEntity, TJoinEntity>
A builder over the joined projection.
Type Parameters
TJoinEntity
FullJoin<TJoinEntity>(QueryCommand<TJoinEntity>, Expression<Func<TEntity, TJoinEntity, bool>>, Action<JoinOptions>?)
Adds a full outer join to the derived query: unmatched rows from both sides
are kept, with the other side's columns set to NULL.
public JoinedEntityBuilder<TEntity, TJoinEntity> FullJoin<TJoinEntity>(QueryCommand<TJoinEntity> query, Expression<Func<TEntity, TJoinEntity, bool>> joinCondition, Action<JoinOptions>? options = null)
Parameters
queryQueryCommand<TJoinEntity>The derived query to join.
joinConditionExpression<Func<TEntity, TJoinEntity, bool>>The join predicate over the two entities.
optionsAction<JoinOptions>Optional per-join configuration, for example
j => j.Global()orj => j.WithStrictness(JoinStrictness.Any).
Returns
- JoinedEntityBuilder<TEntity, TJoinEntity>
A builder over the joined projection.
Type Parameters
TJoinEntity
FullJoin<TJoinEntity>(Expression<Func<TEntity, TJoinEntity, bool>>, Action<JoinOptions>?)
Adds a FULL JOIN over TJoinEntity without an explicit source; TJoinEntity is resolved through this builder's context (From<TJoinEntity>()) and forwarded to the source-explicit overload.
public JoinedEntityBuilder<TEntity, TJoinEntity> FullJoin<TJoinEntity>(Expression<Func<TEntity, TJoinEntity, bool>> joinCondition, Action<JoinOptions>? options = null)
Parameters
joinConditionExpression<Func<TEntity, TJoinEntity, bool>>A predicate relating the current projection to the joined entity.
optionsAction<JoinOptions>Optional per-join configuration; forwarded unchanged to the source-explicit overload.
Returns
- JoinedEntityBuilder<TEntity, TJoinEntity>
A builder over the projection extended with
TJoinEntity.
Type Parameters
TJoinEntityThe entity type of the joined table.
Exceptions
- ArgumentNullException
joinConditionis null.
GroupByCube<TResult>(Expression<Func<TEntity, TResult>>)
Groups by CUBE (columns): the grouped rows plus every combination subtotal. Requires a
dialect that supports it (see SupportsCube).
public EntityBuilder<TEntity> GroupByCube<TResult>(Expression<Func<TEntity, TResult>> exp)
Parameters
expExpression<Func<TEntity, TResult>>
Returns
- EntityBuilder<TEntity>
Type Parameters
TResult
GroupByGroupingSets<TResult>(Expression<Func<TEntity, TResult>>, params int[][])
Groups by an explicit list of grouping sets, e.g. GROUP BY GROUPING SETS ((a, b), (a), ()).
exp declares the full grouping list (an anonymous type / DTO) and each entry of
sets is a set of 0-based indices into that list; an empty set produces the
grand total. Requires a dialect that supports it (see
SupportsGroupingSets).
public EntityBuilder<TEntity> GroupByGroupingSets<TResult>(Expression<Func<TEntity, TResult>> exp, params int[][] sets)
Parameters
expExpression<Func<TEntity, TResult>>setsint[][]
Returns
- EntityBuilder<TEntity>
Type Parameters
TResult
GroupByRollup<TResult>(Expression<Func<TEntity, TResult>>)
Groups by ROLLUP (columns): the grouped rows plus every prefix subtotal and the grand
total. Requires a dialect that supports it (see SupportsRollup).
public EntityBuilder<TEntity> GroupByRollup<TResult>(Expression<Func<TEntity, TResult>> exp)
Parameters
expExpression<Func<TEntity, TResult>>
Returns
- EntityBuilder<TEntity>
Type Parameters
TResult
GroupBy<TResult>(Expression<Func<TEntity, TResult>>)
Groups rows by exp, a single column or an anonymous type/DTO keying on
several columns.
public EntityBuilder<TEntity> GroupBy<TResult>(Expression<Func<TEntity, TResult>> exp)
Parameters
expExpression<Func<TEntity, TResult>>The grouping key selector.
Returns
- EntityBuilder<TEntity>
A builder with the grouping applied.
Type Parameters
TResultThe grouping key type.
GroupJoin<TInner, TKey, TResult>(EntityBuilder<TInner>, Expression<Func<TEntity, TKey>>, Expression<Func<TInner, TKey>>, Expression<Func<TEntity, IEnumerable<TInner>, TResult>>)
Correlates the rows of this query with inner by key and projects each pair
with the grouped inner rows (source.GroupJoin(...)). Rows without a match receive an
empty group.
Supported by the InMemoryDataContext only; SQL providers throw NotSupportedException.
public EntityBuilder<TResult> GroupJoin<TInner, TKey, TResult>(EntityBuilder<TInner> inner, Expression<Func<TEntity, TKey>> outerKeySelector, Expression<Func<TInner, TKey>> innerKeySelector, Expression<Func<TEntity, IEnumerable<TInner>, TResult>> resultSelector)
Parameters
innerEntityBuilder<TInner>outerKeySelectorExpression<Func<TEntity, TKey>>innerKeySelectorExpression<Func<TInner, TKey>>resultSelectorExpression<Func<TEntity, IEnumerable<TInner>, TResult>>
Returns
- EntityBuilder<TResult>
Type Parameters
TInnerTKeyTResult
Having(Expression<Func<TEntity, bool>>)
Adds condition to the HAVING clause, which filters grouped rows. A repeated
call combines the predicates with and.
public EntityBuilder<TEntity> Having(Expression<Func<TEntity, bool>> condition)
Parameters
conditionExpression<Func<TEntity, bool>>The predicate each group must satisfy.
Returns
- EntityBuilder<TEntity>
A builder with the added predicate.
IgnoreFilters()
Disables all global query filters declared for the query's entity type (and for every entity joined by it), so the query reads the unfiltered rows. The current builder is unchanged; the returned builder is a copy with the all-or-nothing scope set. To disable only some filters, use one of the selective overloads.
public EntityBuilder<TEntity> IgnoreFilters()
Returns
- EntityBuilder<TEntity>
A builder that ignores every global query filter.
IgnoreFilters(IEnumerable<string>)
Disables the named global query filters identified by filterKeys on every
entity type in the query. A subsequent call accumulates: the returned builder carries the union
of both scopes. An empty or null filterKeys disables
nothing (mirroring EF Core). The current builder is unchanged.
public EntityBuilder<TEntity> IgnoreFilters(IEnumerable<string> filterKeys)
Parameters
filterKeysIEnumerable<string>The filter keys to disable.
Returns
- EntityBuilder<TEntity>
A builder that ignores the named filters.
IgnoreFilters(IEnumerable<string>, params Type[])
Disables the named global query filters identified by filterKeys only on the
given entityTypes (the intersection of keys and types); an empty
entityTypes means any entity type. A subsequent call accumulates with the
union. The key list is the gate: an empty or null
filterKeys disables nothing even when entity types are supplied. The current
builder is unchanged.
public EntityBuilder<TEntity> IgnoreFilters(IEnumerable<string> filterKeys, params Type[] entityTypes)
Parameters
filterKeysIEnumerable<string>The filter keys to disable.
entityTypesType[]The entity types the disable is scoped to; empty means any entity type.
Returns
- EntityBuilder<TEntity>
A builder that ignores the given named filters on the given entity types.
IgnoreFilters(params Type[])
Disables every global query filter declared for the given entity types, leaving the filters of
other entity types in the query active. A subsequent call accumulates: the returned builder
carries the union of both scopes. An empty or null
entityTypes disables nothing. The current builder is unchanged.
public EntityBuilder<TEntity> IgnoreFilters(params Type[] entityTypes)
Parameters
entityTypesType[]The entity types whose filters are disabled.
Returns
- EntityBuilder<TEntity>
A builder that ignores the filters of the given entity types.
Join(string, Expression<Func<TEntity, TableAlias, bool>>, Action<JoinOptions>?)
Adds an INNER JOIN over the table named table without an explicit source; the right-hand source resolves to table and is read through TableAlias.
public JoinedEntityBuilder<TEntity, TableAlias> Join(string table, Expression<Func<TEntity, TableAlias, bool>> joinCondition, Action<JoinOptions>? options = null)
Parameters
tablestringThe physical table name of the joined source.
joinConditionExpression<Func<TEntity, TableAlias, bool>>A predicate relating the current entity to the joined TableAlias row.
optionsAction<JoinOptions>Optional per-join configuration; forwarded unchanged.
Returns
- JoinedEntityBuilder<TEntity, TableAlias>
A builder over the projection extended with TableAlias.
Remarks
A null joinCondition is accepted and renders no ON clause, matching the explicit form over ctx.From(table).
JoinAlias<TNext, TNextEntity, TJoinEntity>(Func<IDataContext, TNext>, Cte<TJoinEntity>, JoinType, Action<JoinOptions>?)
Alias-join seam over a typed CTE for the conditionless operators; see the conditional counterpart.
public TNext JoinAlias<TNext, TNextEntity, TJoinEntity>(Func<IDataContext, TNext> create, Cte<TJoinEntity> cte, JoinType joinType, Action<JoinOptions>? options = null) where TNext : EntityBuilder<TNextEntity>
Parameters
createFunc<IDataContext, TNext>Creates an empty
TNextbound to this builder's data context.cteCte<TJoinEntity>The CTE descriptor, converted with this builder's context.
joinTypeJoinTypeThe conditionless join kind to add.
optionsAction<JoinOptions>Optional per-join configuration.
Returns
- TNext
A new
TNextcarrying this builder's joins plus the new one.
Type Parameters
TNextThe generated builder type that receives the join chain.
TNextEntityThe projection type
TNextis built over.TJoinEntityThe CTE's projection type.
Exceptions
- ArgumentNullException
createorcteis null.- NotSupportedException
The in-memory provider cannot project named aliases.
JoinAlias<TNext, TNextEntity, TJoinEntity>(Func<IDataContext, TNext>, Cte<TJoinEntity>, Expression<Func<TEntity, TJoinEntity, bool>>, JoinType, Action<JoinOptions>?)
Alias-join seam over a typed CTE for the conditional operators. The descriptor is converted with this builder's context and forwarded to JoinAlias<TNext, TNextEntity, TJoinEntity>(Func<IDataContext, TNext>, EntityBuilder<TJoinEntity>, Expression<Func<TEntity, TJoinEntity, bool>>, JoinType, Action<JoinOptions>?), so the CTE declaration set and the join source match the converted form.
public TNext JoinAlias<TNext, TNextEntity, TJoinEntity>(Func<IDataContext, TNext> create, Cte<TJoinEntity> cte, Expression<Func<TEntity, TJoinEntity, bool>> joinCondition, JoinType joinType = JoinType.Inner, Action<JoinOptions>? options = null) where TNext : EntityBuilder<TNextEntity>
Parameters
createFunc<IDataContext, TNext>Creates an empty
TNextbound to this builder's data context.cteCte<TJoinEntity>The CTE descriptor, converted with this builder's context.
joinConditionExpression<Func<TEntity, TJoinEntity, bool>>A predicate relating the current projection to the joined entity.
joinTypeJoinTypeThe kind of join to add.
optionsAction<JoinOptions>Optional per-join configuration.
Returns
- TNext
A new
TNextcarrying this builder's joins plus the new one.
Type Parameters
TNextThe generated builder type that receives the join chain.
TNextEntityThe projection type
TNextis built over.TJoinEntityThe CTE's projection type.
Exceptions
- ArgumentNullException
create,cteorjoinConditionis null.- NotSupportedException
The in-memory provider cannot project named aliases.
JoinAlias<TNext, TNextEntity, TJoinEntity>(Func<IDataContext, TNext>, EntityBuilder<TJoinEntity>, JoinType, Action<JoinOptions>?)
Alias-join seam for the conditionless operators (CrossJoin/CrossApply/
OuterApply): mirrors the positional conditionless overloads, so the resulting
JoinExpression carries no ON predicate and an explicit
EntityType.
public TNext JoinAlias<TNext, TNextEntity, TJoinEntity>(Func<IDataContext, TNext> create, EntityBuilder<TJoinEntity> _, JoinType joinType, Action<JoinOptions>? options = null) where TNext : EntityBuilder<TNextEntity>
Parameters
createFunc<IDataContext, TNext>Creates an empty
TNextbound to this builder's data context._EntityBuilder<TJoinEntity>The builder identifying the table to join; only its table metadata is used.
joinTypeJoinTypeThe conditionless join kind to add.
optionsAction<JoinOptions>Optional per-join configuration.
Returns
- TNext
A new
TNextcarrying this builder's joins plus the new one.
Type Parameters
TNextThe generated builder type that receives the join chain.
TNextEntityThe projection type
TNextis built over.TJoinEntityThe entity type being joined.
Exceptions
- NotSupportedException
The in-memory provider cannot project named aliases.
JoinAlias<TNext, TNextEntity, TJoinEntity>(Func<IDataContext, TNext>, EntityBuilder<TJoinEntity>, Expression<Func<TEntity, TJoinEntity, bool>>, JoinType, Action<JoinOptions>?)
Seam for generated alias-join builders (issue #113): adds _ as a join and
returns the caller-created builder of a different projection shape, carrying this builder's join
chain. The generated extension method supplies the target type through create
so the projection can expose lexical alias properties (for example p.Buyer) whose
JoinSlotAttribute maps them to the right joined table. This overload serves the
conditional operators (Join/LeftJoin/RightJoin/FullJoin) and delegates
to the same construction path as their positional counterparts, parameterized by
joinType; the in-memory provider refuses it explicitly at construction.
public TNext JoinAlias<TNext, TNextEntity, TJoinEntity>(Func<IDataContext, TNext> create, EntityBuilder<TJoinEntity> _, Expression<Func<TEntity, TJoinEntity, bool>> joinCondition, JoinType joinType = JoinType.Inner, Action<JoinOptions>? options = null) where TNext : EntityBuilder<TNextEntity>
Parameters
createFunc<IDataContext, TNext>Creates an empty
TNextbound to this builder's data context._EntityBuilder<TJoinEntity>The builder identifying the table to join; only its table metadata is used.
joinConditionExpression<Func<TEntity, TJoinEntity, bool>>A predicate relating the current projection to the joined entity.
joinTypeJoinTypeThe kind of join to add.
optionsAction<JoinOptions>Optional per-join configuration.
Returns
- TNext
A new
TNextcarrying this builder's joins plus the new one.
Type Parameters
TNextThe generated builder type that receives the join chain.
TNextEntityThe projection type
TNextis built over.TJoinEntityThe entity type being joined.
Exceptions
- NotSupportedException
The in-memory provider cannot project named aliases.
JoinAlias<TNext, TNextEntity, TJoinEntity>(Func<IDataContext, TNext>, Expression<Func<TEntity, EntityBuilder<TJoinEntity>>>, JoinType, Action<JoinOptions>?)
Correlated alias CROSS APPLY/OUTER APPLY: mirrors the positional
CrossApply<TJoinEntity>(Expression<Func<TEntity, EntityBuilder<TJoinEntity>>>, Action<JoinOptions>?)
overload and carries the source through
NextORM.Core.JoinExpression.ApplySource instead of a plain ON condition.
public TNext JoinAlias<TNext, TNextEntity, TJoinEntity>(Func<IDataContext, TNext> create, Expression<Func<TEntity, EntityBuilder<TJoinEntity>>> source, JoinType joinType, Action<JoinOptions>? options = null) where TNext : EntityBuilder<TNextEntity>
Parameters
createFunc<IDataContext, TNext>Creates an empty
TNextbound to this builder's data context.sourceExpression<Func<TEntity, EntityBuilder<TJoinEntity>>>A lambda receiving the left-hand row and returning the applied builder.
joinTypeJoinTypeThe APPLY kind to add.
optionsAction<JoinOptions>Optional per-join configuration.
Returns
- TNext
A new
TNextcarrying this builder's joins plus the applied source.
Type Parameters
TNextThe generated builder type that receives the join chain.
TNextEntityThe projection type
TNextis built over.TJoinEntityThe entity type yielded by the applied source.
JoinAlias<TNext, TNextEntity, TJoinEntity>(Func<IDataContext, TNext>, Expression<Func<TEntity, QueryCommand<TJoinEntity>>>, JoinType, Action<JoinOptions>?)
Correlated alias CROSS APPLY/OUTER APPLY over a derived query; mirrors the
positional CrossApply<TJoinEntity>(Expression<Func<TEntity, QueryCommand<TJoinEntity>>>, Action<JoinOptions>?)
overload.
public TNext JoinAlias<TNext, TNextEntity, TJoinEntity>(Func<IDataContext, TNext> create, Expression<Func<TEntity, QueryCommand<TJoinEntity>>> source, JoinType joinType, Action<JoinOptions>? options = null) where TNext : EntityBuilder<TNextEntity>
Parameters
createFunc<IDataContext, TNext>Creates an empty
TNextbound to this builder's data context.sourceExpression<Func<TEntity, QueryCommand<TJoinEntity>>>A lambda receiving the left-hand row and returning the applied query.
joinTypeJoinTypeThe APPLY kind to add.
optionsAction<JoinOptions>Optional per-join configuration.
Returns
- TNext
A new
TNextcarrying this builder's joins plus the applied query.
Type Parameters
TNextThe generated builder type that receives the join chain.
TNextEntityThe projection type
TNextis built over.TJoinEntityThe entity type yielded by the applied query.
JoinAlias<TNext, TNextEntity, TJoinEntity>(Func<IDataContext, TNext>, Expression<Func<TEntity, TJoinEntity, bool>>, JoinType, Action<JoinOptions>?)
Source-less alias-join seam for generated alias-join builders (issue #322): the implicit
FROM source for TJoinEntity is created from this builder's data
context (From<TJoinEntity>()) and forwarded to the same assembly path as the
source-explicit conditional overload, so a generated extension method can expose the
Alias.X marker without also handing the caller an EntityBuilder<TJoinEntity>.
public TNext JoinAlias<TNext, TNextEntity, TJoinEntity>(Func<IDataContext, TNext> create, Expression<Func<TEntity, TJoinEntity, bool>> joinCondition, JoinType joinType = JoinType.Inner, Action<JoinOptions>? options = null) where TNext : EntityBuilder<TNextEntity>
Parameters
createFunc<IDataContext, TNext>Creates an empty
TNextbound to this builder's data context.joinConditionExpression<Func<TEntity, TJoinEntity, bool>>A predicate relating the current projection to the joined entity.
joinTypeJoinTypeThe kind of join to add.
optionsAction<JoinOptions>Optional per-join configuration; applied exactly once by the shared assembly path.
Returns
- TNext
A new
TNextcarrying this builder's joins plus the new one.
Type Parameters
TNextThe generated builder type that receives the join chain.
TNextEntityThe projection type
TNextis built over.TJoinEntityThe entity type being joined.
Exceptions
- ArgumentNullException
createorjoinConditionis null.- NotSupportedException
The in-memory provider cannot project named aliases.
JoinInto<TChild>(EntityBuilder<TChild>, Expression<Func<TEntity, TChild, bool>>, Expression<Func<TEntity, ICollection<TChild>>>, JoinType, Action<JoinOptions>?)
Declares a typed join to child (see
JoinInto<TChild>(EntityBuilder<TChild>, Expression<Func<TEntity, TChild, bool>>, Expression<Func<TEntity, ICollection<TChild>>>, Action<JoinOptions>?))
that fills the collection member. Only Inner and
Left are accepted; any other kind throws NotSupportedException.
The returned builder is a copy; the current builder is unchanged.
public EntityBuilder<TEntity> JoinInto<TChild>(EntityBuilder<TChild> child, Expression<Func<TEntity, TChild, bool>> predicate, Expression<Func<TEntity, ICollection<TChild>>> collection, JoinType joinType, Action<JoinOptions>? options = null)
Parameters
childEntityBuilder<TChild>The child source.
predicateExpression<Func<TEntity, TChild, bool>>The join predicate over the parent and child.
collectionExpression<Func<TEntity, ICollection<TChild>>>The parent-side collection member the joined children fill.
joinTypeJoinTypeoptionsAction<JoinOptions>Optional per-join configuration, for example
j => j.Global()orj => j.WithStrictness(JoinStrictness.Any).
Returns
- EntityBuilder<TEntity>
A copy of this builder carrying the join declaration.
Type Parameters
TChildThe child entity type.
Remarks
A Where declared on the child source is folded into the join's ON condition together
with predicate, so a matched parent keeps only the filtered children while a
LEFT join still keeps a parent whose children are all filtered out. Only the child's own
Where is supported: any other child-query modifier (ordering, paging, Distinct,
grouping, joins, a table modifier or a nested eager load) throws
NotSupportedException at the declaration, before the query is prepared or executed. A
derived (As) child source is supported when its only modifier is its own
Where; any other modifier on or inside it is rejected the same way.
Exceptions
- NotSupportedException
The join kind or relationship is not supported.
JoinInto<TChild>(EntityBuilder<TChild>, Expression<Func<TEntity, TChild, bool>>, Expression<Func<TEntity, ICollection<TChild>>>, Action<JoinOptions>?)
Declares a LEFT JOIN to child that fills the collection
member of every parent when the query is enumerated by a list terminal. The returned builder is a
copy; the current builder is unchanged.
The join is part of the query: ToCommand() emits
... from Parent as t1 left join Child as t2 on <predicate> while still materializing
TEntity rows, so a bare ToCommand() may repeat a parent once
per matching child. The parent/child keys are resolved from the declared relationship metadata (or
from a local JoinOptions configuration, which fully replaces the metadata for this
call); a composite principal/foreign key is supported componentwise. A relationship that is not
declared, a many-to-many without a junction, or a composite-junction many-to-many (carried by
issue #223) is rejected with NotSupportedException — use the explicit-key overload
instead.
The list terminals
execute one denormalized command and stitch the children onto the deduplicated parents; the
non-list terminals exclude this join and evaluate the parent only.
public EntityBuilder<TEntity> JoinInto<TChild>(EntityBuilder<TChild> child, Expression<Func<TEntity, TChild, bool>> predicate, Expression<Func<TEntity, ICollection<TChild>>> collection, Action<JoinOptions>? options = null)
Parameters
childEntityBuilder<TChild>The child source.
predicateExpression<Func<TEntity, TChild, bool>>The join predicate over the parent and child.
collectionExpression<Func<TEntity, ICollection<TChild>>>The parent-side collection member the joined children fill.
optionsAction<JoinOptions>Optional per-join configuration, for example
j => j.Global()orj => j.WithStrictness(JoinStrictness.Any).
Returns
- EntityBuilder<TEntity>
A copy of this builder carrying the join declaration.
Type Parameters
TChildThe child entity type.
Exceptions
- NotSupportedException
The join kind or relationship is not supported.
JoinInto<TChild>(EntityBuilder<TChild>, Expression<Func<TEntity, TChild, bool>>, Expression<Func<TEntity, TChild?>>, JoinType, Action<JoinOptions>?)
Declares a typed join to child (see
JoinInto<TChild>(EntityBuilder<TChild>, Expression<Func<TEntity, TChild, bool>>, Expression<Func<TEntity, TChild?>>, Action<JoinOptions>?))
that assigns the single joined child to the one-to-one navigation reference.
Only Inner and Left are accepted; any other kind
throws NotSupportedException. The returned builder is a copy; the current builder is
unchanged.
public EntityBuilder<TEntity> JoinInto<TChild>(EntityBuilder<TChild> child, Expression<Func<TEntity, TChild, bool>> predicate, Expression<Func<TEntity, TChild?>> navigation, JoinType joinType, Action<JoinOptions>? options = null) where TChild : class
Parameters
childEntityBuilder<TChild>The child source.
predicateExpression<Func<TEntity, TChild, bool>>The join predicate over the parent and child.
navigationExpression<Func<TEntity, TChild>>The parent-side reference navigation the joined child fills.
joinTypeJoinTypeoptionsAction<JoinOptions>Optional per-join configuration, for example
j => j.Global()orj => j.WithStrictness(JoinStrictness.Any).
Returns
- EntityBuilder<TEntity>
A copy of this builder carrying the join declaration.
Type Parameters
TChildThe child entity type.
Remarks
A Where declared on the child source is folded into the join's ON condition together
with predicate, so a matched parent keeps only the filtered child while a
LEFT join still keeps a parent whose child is filtered out (the reference stays
null). Only the child's own Where is supported: any other child-query
modifier throws NotSupportedException at the declaration, before the query is
prepared or executed. A derived (As) child source is supported when its only modifier is
its own Where; any other modifier on or inside it is rejected the same way.
Exceptions
- NotSupportedException
The join kind, relationship kind or keys are not supported.
JoinInto<TChild>(EntityBuilder<TChild>, Expression<Func<TEntity, TChild, bool>>, Expression<Func<TEntity, TChild?>>, Action<JoinOptions>?)
Declares a LEFT JOIN to child that assigns the single joined child to the
one-to-one navigation reference of every parent when the query is enumerated by a
list terminal. The returned builder is a copy; the current builder is unchanged.
The relationship must be declared as one-to-one (HasOneToOne) so the principal/foreign keys
are known. The foreign-key uniqueness is a declaration-time trust: the core neither inspects the
schema or the data nor imposes a uniqueness constraint. At most one child is assigned per parent; a
LEFT join leaves the reference null when no child matches, while an
INNER join excludes the parent. A parent that matches more than one distinct non-null child
identity throws InvalidOperationException at materialization. Repeated rows of the
same child identity are tolerated (the first child wins), including cartesian repeats caused by a
neighbouring join and keyless/null-identity children, for which the core cannot distinguish a
repeat from a genuinely different child.
public EntityBuilder<TEntity> JoinInto<TChild>(EntityBuilder<TChild> child, Expression<Func<TEntity, TChild, bool>> predicate, Expression<Func<TEntity, TChild?>> navigation, Action<JoinOptions>? options = null) where TChild : class
Parameters
childEntityBuilder<TChild>The child source.
predicateExpression<Func<TEntity, TChild, bool>>The join predicate over the parent and child.
navigationExpression<Func<TEntity, TChild>>The parent-side reference navigation the joined child fills.
optionsAction<JoinOptions>Optional per-join configuration, for example
j => j.Global()orj => j.WithStrictness(JoinStrictness.Any).
Returns
- EntityBuilder<TEntity>
A copy of this builder carrying the join declaration.
Type Parameters
TChildThe child entity type.
Exceptions
- NotSupportedException
The join kind, relationship kind or keys are not supported.
JoinInto<TChild>(Expression<Func<TEntity, ICollection<TChild>>>, Expression<Func<TEntity, TChild, bool>>?, Action<JoinOptions>?)
Declares a LEFT JOIN to the mapping of TChild that fills the
collection member of every parent, taking both join keys from the relationship
the navigation declares. The navigation selects the relationship, so the caller does not restate
its keys: the ON condition is the ordered principal/foreign component equality of the
declared relationship, conjoined componentwise (a composite key contributes one equality per
component, in declaration order).
filter is an additional restriction appended to that ON condition
as one more conjunct; it never replaces the declared-key equality and is never moved into a
parent-filtering WHERE, so a parent whose children are all filtered out is still returned
with an empty collection. null means no additional restriction. For a many-to-many
navigation the existing junction synthesis supplies both key edges, and the filter is appended to
the link-to-child edge exactly where the explicit forms append their predicate.
The child source is the mapping of TChild resolved from the data context -
the same resolution the source-less overloads use, so a configured mapping keeps precedence. The
returned builder is a copy; the current builder is unchanged.
public EntityBuilder<TEntity> JoinInto<TChild>(Expression<Func<TEntity, ICollection<TChild>>> collection, Expression<Func<TEntity, TChild, bool>>? filter = null, Action<JoinOptions>? options = null)
Parameters
collectionExpression<Func<TEntity, ICollection<TChild>>>The parent-side collection navigation the joined children fill.
filterExpression<Func<TEntity, TChild, bool>>An additional predicate over the parent and child, conjoined into the join's
ON; null for no additional restriction.optionsAction<JoinOptions>Optional per-join configuration, for example
j => j.Global()orj => j.WithStrictness(JoinStrictness.Any).
Returns
- EntityBuilder<TEntity>
A copy of this builder carrying the join declaration.
Type Parameters
TChildThe child entity type, inferred from the collection navigation.
Exceptions
- ArgumentNullException
collectionis null.- NotSupportedException
The navigation does not resolve to a declared relationship, the cardinality or the keys are unsupported, or the key type has no value equality.
JoinInto<TChild>(Expression<Func<TEntity, TChild, bool>>, Expression<Func<TEntity, ICollection<TChild>>>, JoinType, Action<JoinOptions>?)
Declares a typed join to the mapping of TChild (see
JoinInto<TChild>(Expression<Func<TEntity, TChild, bool>>, Expression<Func<TEntity, ICollection<TChild>>>, Action<JoinOptions>?))
that fills the collection member and uses the given joinType.
Only Inner and Left are accepted; any other kind throws
NotSupportedException. The returned builder is a copy; the current builder is unchanged.
public EntityBuilder<TEntity> JoinInto<TChild>(Expression<Func<TEntity, TChild, bool>> predicate, Expression<Func<TEntity, ICollection<TChild>>> collection, JoinType joinType, Action<JoinOptions>? options = null)
Parameters
predicateExpression<Func<TEntity, TChild, bool>>The join predicate over the parent and child.
collectionExpression<Func<TEntity, ICollection<TChild>>>The parent-side collection member the joined children fill.
joinTypeJoinTypeoptionsAction<JoinOptions>Optional per-join configuration, for example
j => j.Global()orj => j.WithStrictness(JoinStrictness.Any).
Returns
- EntityBuilder<TEntity>
A copy of this builder carrying the join declaration.
Type Parameters
TChildThe child entity type.
Exceptions
- NotSupportedException
The join kind or relationship is not supported.
JoinInto<TChild>(Expression<Func<TEntity, TChild, bool>>, Expression<Func<TEntity, ICollection<TChild>>>, Action<JoinOptions>?)
Declares a LEFT JOIN to the mapping of TChild that fills the
collection member of every parent when the query is enumerated by a list
terminal. The child source is the mapping of TChild, so no child builder is
supplied. The returned builder is a copy; the current builder is unchanged.
Equivalent to JoinInto<TChild>(EntityBuilder<TChild>, Expression<Func<TEntity, TChild, bool>>, Expression<Func<TEntity, ICollection<TChild>>>, Action<JoinOptions>?) with the child source resolved from the data context; the parent/child keys are resolved from the declared relationship metadata (or from a local JoinOptions configuration) and a relationship that cannot be resolved is rejected with NotSupportedException.
public EntityBuilder<TEntity> JoinInto<TChild>(Expression<Func<TEntity, TChild, bool>> predicate, Expression<Func<TEntity, ICollection<TChild>>> collection, Action<JoinOptions>? options = null)
Parameters
predicateExpression<Func<TEntity, TChild, bool>>The join predicate over the parent and child.
collectionExpression<Func<TEntity, ICollection<TChild>>>The parent-side collection member the joined children fill.
optionsAction<JoinOptions>Optional per-join configuration, for example
j => j.Global()orj => j.WithStrictness(JoinStrictness.Any).
Returns
- EntityBuilder<TEntity>
A copy of this builder carrying the join declaration.
Type Parameters
TChildThe child entity type.
Exceptions
- NotSupportedException
The join kind or relationship is not supported.
JoinInto<TChild>(Expression<Func<TEntity, TChild, bool>>, Expression<Func<TEntity, TChild?>>, JoinType, Action<JoinOptions>?)
Declares a typed join to the mapping of TChild (see
JoinInto<TChild>(Expression<Func<TEntity, TChild, bool>>, Expression<Func<TEntity, TChild?>>, Action<JoinOptions>?))
that assigns the single joined child to the one-to-one navigation reference and
uses the given joinType. Only Inner and
Left are accepted; any other kind throws NotSupportedException.
The returned builder is a copy; the current builder is unchanged.
public EntityBuilder<TEntity> JoinInto<TChild>(Expression<Func<TEntity, TChild, bool>> predicate, Expression<Func<TEntity, TChild?>> navigation, JoinType joinType, Action<JoinOptions>? options = null) where TChild : class
Parameters
predicateExpression<Func<TEntity, TChild, bool>>The join predicate over the parent and child.
navigationExpression<Func<TEntity, TChild>>The parent-side reference navigation the joined child fills.
joinTypeJoinTypeoptionsAction<JoinOptions>Optional per-join configuration, for example
j => j.Global()orj => j.WithStrictness(JoinStrictness.Any).
Returns
- EntityBuilder<TEntity>
A copy of this builder carrying the join declaration.
Type Parameters
TChildThe child entity type.
Exceptions
- NotSupportedException
The join kind, relationship kind or keys are not supported.
JoinInto<TChild>(Expression<Func<TEntity, TChild, bool>>, Expression<Func<TEntity, TChild?>>, Action<JoinOptions>?)
Declares a LEFT JOIN to the mapping of TChild that assigns the single
joined child to the one-to-one navigation reference of every parent when the query
is enumerated by a list terminal. The child source is the mapping of TChild, so
no child builder is supplied. The returned builder is a copy; the current builder is unchanged.
Equivalent to JoinInto<TChild>(EntityBuilder<TChild>, Expression<Func<TEntity, TChild, bool>>, Expression<Func<TEntity, TChild?>>, Action<JoinOptions>?) with the child source resolved from the data context. The relationship must be declared as one-to-one so the principal/foreign keys are known; an unresolvable relationship is rejected with NotSupportedException.
public EntityBuilder<TEntity> JoinInto<TChild>(Expression<Func<TEntity, TChild, bool>> predicate, Expression<Func<TEntity, TChild?>> navigation, Action<JoinOptions>? options = null) where TChild : class
Parameters
predicateExpression<Func<TEntity, TChild, bool>>The join predicate over the parent and child.
navigationExpression<Func<TEntity, TChild>>The parent-side reference navigation the joined child fills.
optionsAction<JoinOptions>Optional per-join configuration, for example
j => j.Global()orj => j.WithStrictness(JoinStrictness.Any).
Returns
- EntityBuilder<TEntity>
A copy of this builder carrying the join declaration.
Type Parameters
TChildThe child entity type.
Exceptions
- NotSupportedException
The join kind, relationship kind or keys are not supported.
JoinInto<TChild>(Expression<Func<TEntity, TChild?>>, Expression<Func<TEntity, TChild, bool>>?, Action<JoinOptions>?)
Declares a LEFT JOIN to the mapping of TChild that assigns the single
joined child to the one-to-one navigation reference of every parent, taking both
join keys from the relationship the navigation declares. The navigation selects the relationship,
so the caller does not restate its keys: the ON condition is the ordered principal/foreign
component equality of the declared relationship, conjoined componentwise.
filter is an additional restriction appended to that ON condition
as one more conjunct; it never replaces the declared-key equality and is never moved into a
parent-filtering WHERE, so a parent whose only candidate child is filtered out keeps a
null reference instead of disappearing. null means no
additional restriction. At most one child is assigned per parent, as for the explicit forms.
The child source is the mapping of TChild resolved from the data context -
the same resolution the source-less overloads use, so a configured mapping keeps precedence. The
returned builder is a copy; the current builder is unchanged.
public EntityBuilder<TEntity> JoinInto<TChild>(Expression<Func<TEntity, TChild?>> navigation, Expression<Func<TEntity, TChild, bool>>? filter = null, Action<JoinOptions>? options = null) where TChild : class
Parameters
navigationExpression<Func<TEntity, TChild>>The parent-side reference navigation the joined child fills.
filterExpression<Func<TEntity, TChild, bool>>An additional predicate over the parent and child, conjoined into the join's
ON; null for no additional restriction.optionsAction<JoinOptions>Optional per-join configuration, for example
j => j.Global()orj => j.WithStrictness(JoinStrictness.Any).
Returns
- EntityBuilder<TEntity>
A copy of this builder carrying the join declaration.
Type Parameters
TChildThe child entity type, inferred from the reference navigation.
Exceptions
- ArgumentNullException
navigationis null.- NotSupportedException
The navigation does not resolve to a declared one-to-one relationship, the navigation has no setter, or the key type has no value equality.
JoinInto<TChild, TKey>(EntityBuilder<TChild>, Expression<Func<TEntity, TChild, bool>>, Expression<Func<TEntity, ICollection<TChild>>>, Expression<Func<TEntity, TKey>>, Expression<Func<TChild, TKey>>, Action<JoinOptions>?)
Declares a LEFT JOIN to child that fills the collection
member, using the explicit parentKey/childKey selectors
instead of declared relationship metadata (symmetrical to the LoadWith fallback). The
returned builder is a copy; the current builder is unchanged.
public EntityBuilder<TEntity> JoinInto<TChild, TKey>(EntityBuilder<TChild> child, Expression<Func<TEntity, TChild, bool>> predicate, Expression<Func<TEntity, ICollection<TChild>>> collection, Expression<Func<TEntity, TKey>> parentKey, Expression<Func<TChild, TKey>> childKey, Action<JoinOptions>? options = null) where TKey : notnull
Parameters
childEntityBuilder<TChild>The child source.
predicateExpression<Func<TEntity, TChild, bool>>The join predicate over the parent and child.
collectionExpression<Func<TEntity, ICollection<TChild>>>The parent-side collection member the joined children fill.
parentKeyExpression<Func<TEntity, TKey>>Selects the parent key used to group the rows.
childKeyExpression<Func<TChild, TKey>>Selects the child key used to group the rows.
optionsAction<JoinOptions>Optional per-join configuration, for example
j => j.Global()orj => j.WithStrictness(JoinStrictness.Any).
Returns
- EntityBuilder<TEntity>
A copy of this builder carrying the join declaration.
Type Parameters
TChildThe child entity type.
TKeyThe non-nullable key type shared by the two selectors.
Remarks
A Where declared on the child source is folded into the join's ON condition together
with predicate, so a matched parent keeps only the filtered children while the
LEFT join still keeps a parent whose children are all filtered out. Only the child's own
Where is supported: any other child-query modifier throws
NotSupportedException at the declaration, before the query is prepared or executed. A
derived (As) child source is supported when its only modifier is its own
Where; any other modifier on or inside it is rejected the same way.
Exceptions
- NotSupportedException
The key selectors select different types.
JoinInto<TChild, TKey>(Expression<Func<TEntity, TChild, bool>>, Expression<Func<TEntity, ICollection<TChild>>>, Expression<Func<TEntity, TKey>>, Expression<Func<TChild, TKey>>, Action<JoinOptions>?)
Declares a LEFT JOIN to the mapping of TChild that fills the
collection member, using the explicit
parentKey/childKey selectors instead of declared relationship
metadata. The child source is the mapping of TChild, so no child builder is
supplied; the call is equivalent to
JoinInto<TChild, TKey>(EntityBuilder<TChild>, Expression<Func<TEntity, TChild, bool>>, Expression<Func<TEntity, ICollection<TChild>>>, Expression<Func<TEntity, TKey>>, Expression<Func<TChild, TKey>>, Action<JoinOptions>?)
with the child source resolved from the data context. The returned builder is a copy; the current
builder is unchanged.
public EntityBuilder<TEntity> JoinInto<TChild, TKey>(Expression<Func<TEntity, TChild, bool>> predicate, Expression<Func<TEntity, ICollection<TChild>>> collection, Expression<Func<TEntity, TKey>> parentKey, Expression<Func<TChild, TKey>> childKey, Action<JoinOptions>? options = null) where TKey : notnull
Parameters
predicateExpression<Func<TEntity, TChild, bool>>The join predicate over the parent and child.
collectionExpression<Func<TEntity, ICollection<TChild>>>The parent-side collection member the joined children fill.
parentKeyExpression<Func<TEntity, TKey>>Selects the parent key used to group the rows.
childKeyExpression<Func<TChild, TKey>>Selects the child key used to group the rows.
optionsAction<JoinOptions>Optional per-join configuration, for example
j => j.Global()orj => j.WithStrictness(JoinStrictness.Any).
Returns
- EntityBuilder<TEntity>
A copy of this builder carrying the join declaration.
Type Parameters
TChildThe child entity type.
TKeyThe non-nullable key type shared by the two selectors.
Exceptions
- NotSupportedException
The key selectors select different types.
Join<TJoinEntity>(Cte<TJoinEntity>, Expression<Func<TEntity, TJoinEntity, bool>>)
Adds an inner join over the typed CTE cte; identical to Join<TJoinEntity>(EntityBuilder<TJoinEntity>, Expression<Func<TEntity, TJoinEntity, bool>>, Action<JoinOptions>?) with this builder's context.
public JoinedEntityBuilder<TEntity, TJoinEntity> Join<TJoinEntity>(Cte<TJoinEntity> cte, Expression<Func<TEntity, TJoinEntity, bool>> joinCondition)
Parameters
cteCte<TJoinEntity>The CTE descriptor, converted with this builder's context.
joinConditionExpression<Func<TEntity, TJoinEntity, bool>>The join predicate over the two entities.
Returns
- JoinedEntityBuilder<TEntity, TJoinEntity>
A builder over the joined projection.
Type Parameters
TJoinEntityThe CTE's projection type.
Exceptions
- ArgumentNullException
cteorjoinConditionis null.
Join<TJoinEntity>(Cte<TJoinEntity>, Expression<Func<TEntity, TJoinEntity, bool>>, Action<JoinOptions>?)
Adds an inner join over the typed CTE cte with per-join options.
public JoinedEntityBuilder<TEntity, TJoinEntity> Join<TJoinEntity>(Cte<TJoinEntity> cte, Expression<Func<TEntity, TJoinEntity, bool>> joinCondition, Action<JoinOptions>? options)
Parameters
cteCte<TJoinEntity>The CTE descriptor, converted with this builder's context.
joinConditionExpression<Func<TEntity, TJoinEntity, bool>>The join predicate over the two entities.
optionsAction<JoinOptions>Per-join configuration.
Returns
- JoinedEntityBuilder<TEntity, TJoinEntity>
A builder over the joined projection.
Type Parameters
TJoinEntityThe CTE's projection type.
Exceptions
- ArgumentNullException
cteorjoinConditionis null.
Join<TJoinEntity>(EntityBuilder<TJoinEntity>, Expression<Func<TEntity, TJoinEntity, bool>>, Action<JoinOptions>?)
Adds an inner join to _, using joinCondition as the
ON predicate; only matching pairs survive.
public JoinedEntityBuilder<TEntity, TJoinEntity> Join<TJoinEntity>(EntityBuilder<TJoinEntity> _, Expression<Func<TEntity, TJoinEntity, bool>> joinCondition, Action<JoinOptions>? options = null)
Parameters
_EntityBuilder<TJoinEntity>The builder for the joined entity; only its source is used.
joinConditionExpression<Func<TEntity, TJoinEntity, bool>>The join predicate over the two entities.
optionsAction<JoinOptions>Optional per-join configuration, for example
j => j.Global()orj => j.WithStrictness(JoinStrictness.Any).
Returns
- JoinedEntityBuilder<TEntity, TJoinEntity>
A builder over the joined projection.
Type Parameters
TJoinEntity
Join<TJoinEntity>(QueryCommand<TJoinEntity>, Expression<Func<TEntity, TJoinEntity, bool>>, Action<JoinOptions>?)
Adds an inner join to the derived query, using
joinCondition as the ON predicate; only matching pairs survive.
public JoinedEntityBuilder<TEntity, TJoinEntity> Join<TJoinEntity>(QueryCommand<TJoinEntity> query, Expression<Func<TEntity, TJoinEntity, bool>> joinCondition, Action<JoinOptions>? options = null)
Parameters
queryQueryCommand<TJoinEntity>The derived query to join.
joinConditionExpression<Func<TEntity, TJoinEntity, bool>>The join predicate over the two entities.
optionsAction<JoinOptions>Optional per-join configuration, for example
j => j.Global()orj => j.WithStrictness(JoinStrictness.Any).
Returns
- JoinedEntityBuilder<TEntity, TJoinEntity>
A builder over the joined projection.
Type Parameters
TJoinEntity
Join<TJoinEntity>(Expression<Func<TEntity, TJoinEntity, bool>>, Action<JoinOptions>?)
Adds an INNER JOIN over TJoinEntity without an explicit source; TJoinEntity is resolved through this builder's context (From<TJoinEntity>()) and forwarded to the source-explicit overload.
public JoinedEntityBuilder<TEntity, TJoinEntity> Join<TJoinEntity>(Expression<Func<TEntity, TJoinEntity, bool>> joinCondition, Action<JoinOptions>? options = null)
Parameters
joinConditionExpression<Func<TEntity, TJoinEntity, bool>>A predicate relating the current projection to the joined entity.
optionsAction<JoinOptions>Optional per-join configuration; forwarded unchanged to the source-explicit overload.
Returns
- JoinedEntityBuilder<TEntity, TJoinEntity>
A builder over the projection extended with
TJoinEntity.
Type Parameters
TJoinEntityThe entity type of the joined table.
Exceptions
- ArgumentNullException
joinConditionis null.
LeftJoin(string, Expression<Func<TEntity, TableAlias, bool>>, Action<JoinOptions>?)
Adds a LEFT JOIN over the table named table without an explicit source.
public JoinedEntityBuilder<TEntity, TableAlias> LeftJoin(string table, Expression<Func<TEntity, TableAlias, bool>> joinCondition, Action<JoinOptions>? options = null)
Parameters
tablestringThe physical table name of the joined source.
joinConditionExpression<Func<TEntity, TableAlias, bool>>A predicate relating the current entity to the joined TableAlias row.
optionsAction<JoinOptions>Optional per-join configuration; forwarded unchanged.
Returns
- JoinedEntityBuilder<TEntity, TableAlias>
A builder over the projection extended with TableAlias.
Remarks
A null joinCondition is accepted and renders no ON clause, matching the explicit form over ctx.From(table).
LeftJoin<TJoinEntity>(Cte<TJoinEntity>, Expression<Func<TEntity, TJoinEntity, bool>>)
Adds a left outer join over the typed CTE cte.
public JoinedEntityBuilder<TEntity, TJoinEntity> LeftJoin<TJoinEntity>(Cte<TJoinEntity> cte, Expression<Func<TEntity, TJoinEntity, bool>> joinCondition)
Parameters
cteCte<TJoinEntity>The CTE descriptor, converted with this builder's context.
joinConditionExpression<Func<TEntity, TJoinEntity, bool>>The join predicate over the two entities.
Returns
- JoinedEntityBuilder<TEntity, TJoinEntity>
A builder over the joined projection.
Type Parameters
TJoinEntityThe CTE's projection type.
Exceptions
- ArgumentNullException
cteorjoinConditionis null.
LeftJoin<TJoinEntity>(Cte<TJoinEntity>, Expression<Func<TEntity, TJoinEntity, bool>>, Action<JoinOptions>?)
Adds a left outer join over the typed CTE cte with per-join options.
public JoinedEntityBuilder<TEntity, TJoinEntity> LeftJoin<TJoinEntity>(Cte<TJoinEntity> cte, Expression<Func<TEntity, TJoinEntity, bool>> joinCondition, Action<JoinOptions>? options)
Parameters
cteCte<TJoinEntity>The CTE descriptor, converted with this builder's context.
joinConditionExpression<Func<TEntity, TJoinEntity, bool>>The join predicate over the two entities.
optionsAction<JoinOptions>Per-join configuration.
Returns
- JoinedEntityBuilder<TEntity, TJoinEntity>
A builder over the joined projection.
Type Parameters
TJoinEntityThe CTE's projection type.
Exceptions
- ArgumentNullException
cteorjoinConditionis null.
LeftJoin<TJoinEntity>(EntityBuilder<TJoinEntity>, Expression<Func<TEntity, TJoinEntity, bool>>, Action<JoinOptions>?)
Adds a left outer join: every left-hand row is kept, and right-hand columns are NULL
when there is no match.
public JoinedEntityBuilder<TEntity, TJoinEntity> LeftJoin<TJoinEntity>(EntityBuilder<TJoinEntity> _, Expression<Func<TEntity, TJoinEntity, bool>> joinCondition, Action<JoinOptions>? options = null)
Parameters
_EntityBuilder<TJoinEntity>The builder for the joined entity; only its source is used.
joinConditionExpression<Func<TEntity, TJoinEntity, bool>>The join predicate over the two entities.
optionsAction<JoinOptions>Optional per-join configuration, for example
j => j.Global()orj => j.WithStrictness(JoinStrictness.Any).
Returns
- JoinedEntityBuilder<TEntity, TJoinEntity>
A builder over the joined projection.
Type Parameters
TJoinEntity
LeftJoin<TJoinEntity>(QueryCommand<TJoinEntity>, Expression<Func<TEntity, TJoinEntity, bool>>, Action<JoinOptions>?)
Adds a left outer join to the derived query: every left-hand row is kept,
and right-hand columns are NULL when there is no match.
public JoinedEntityBuilder<TEntity, TJoinEntity> LeftJoin<TJoinEntity>(QueryCommand<TJoinEntity> query, Expression<Func<TEntity, TJoinEntity, bool>> joinCondition, Action<JoinOptions>? options = null)
Parameters
queryQueryCommand<TJoinEntity>The derived query to join.
joinConditionExpression<Func<TEntity, TJoinEntity, bool>>The join predicate over the two entities.
optionsAction<JoinOptions>Optional per-join configuration, for example
j => j.Global()orj => j.WithStrictness(JoinStrictness.Any).
Returns
- JoinedEntityBuilder<TEntity, TJoinEntity>
A builder over the joined projection.
Type Parameters
TJoinEntity
LeftJoin<TJoinEntity>(Expression<Func<TEntity, TJoinEntity, bool>>, Action<JoinOptions>?)
Adds a LEFT JOIN over TJoinEntity without an explicit source; TJoinEntity is resolved through this builder's context (From<TJoinEntity>()) and forwarded to the source-explicit overload.
public JoinedEntityBuilder<TEntity, TJoinEntity> LeftJoin<TJoinEntity>(Expression<Func<TEntity, TJoinEntity, bool>> joinCondition, Action<JoinOptions>? options = null)
Parameters
joinConditionExpression<Func<TEntity, TJoinEntity, bool>>A predicate relating the current projection to the joined entity.
optionsAction<JoinOptions>Optional per-join configuration; forwarded unchanged to the source-explicit overload.
Returns
- JoinedEntityBuilder<TEntity, TJoinEntity>
A builder over the projection extended with
TJoinEntity.
Type Parameters
TJoinEntityThe entity type of the joined table.
Exceptions
- ArgumentNullException
joinConditionis null.
Limit(int)
Sets the maximum number of rows to return; zero means no limit.
public EntityBuilder<TEntity> Limit(int limit)
Parameters
limitintThe page size; must be non-negative.
Returns
- EntityBuilder<TEntity>
A builder with the new limit.
LoadWith<TChild>(Expression<Func<TEntity, ICollection<TChild>>>, EagerLoadMode)
Declares the eager loading of a declared collection navigation without explicit key
selectors: the relationship is read from the mapping metadata — HasMany or
HasManyThrough (fluent) or [Relationship] — and its ordered key components are
paired positionally, parent component at position i with child component at position
i.
The relationship is resolved and structurally validated when this method is called, so an undeclared navigation, a reference cardinality and malformed metadata are rejected before any SQL is generated and before any plan-cache entry exists. nextorm never infers a relationship from a naming convention, never matches key columns by name and never falls back to the first component of a composite key. A collection navigation can only be loaded through this collection route; the reference route rejects a collection relationship.
The child query is the context's ordinary From<TChild>() source, so the related
type's mapping and global filters apply; use the childQuery overload to add the child's own
filters, ordering or per-parent paging. Modes, chunking, the assignment rule, ordering and the
stitching terminals are the same as for the explicit-key overload. The declared-metadata form is
SQL-only: the in-memory provider rejects it while the parent command is constructed, before any SQL
and before any plan-cache entry.
public EntityBuilder<TEntity> LoadWith<TChild>(Expression<Func<TEntity, ICollection<TChild>>> collection, EagerLoadMode mode = EagerLoadMode.Default)
Parameters
collectionExpression<Func<TEntity, ICollection<TChild>>>The parent-side collection navigation to fill.
modeEagerLoadModeThe whole-builder eager-load mode; Default inherits the current choice.
Returns
- EntityBuilder<TEntity>
A copy of this builder carrying the eager-load declaration.
Type Parameters
TChildThe related entity type.
Exceptions
- ArgumentOutOfRangeException
modeis not a defined value.- InvalidOperationException
The navigation already carries an eager-load declaration on this builder.
- NotSupportedException
The selector is not a collection navigation, no relationship is declared for it, the declared relationship is not a collection relationship of
TChild, its key lists are structurally invalid, a different explicit mode is already active, or the context is the in-memory provider.
LoadWith<TChild>(Expression<Func<TEntity, ICollection<TChild>>>, Func<IDataContext, EntityBuilder<TChild>>, EagerLoadMode)
Declares the eager loading of a declared collection navigation through a child query,
without explicit key selectors: the relationship is read from the mapping metadata — HasMany
or HasManyThrough (fluent) or [Relationship] — and its ordered key components are
paired positionally.
The relationship is resolved and structurally validated when this method is called, so an undeclared navigation, a reference cardinality and malformed metadata are rejected before any SQL is generated and before any plan-cache entry exists. nextorm never infers a relationship from a naming convention, never matches key columns by name and never falls back to the first component of a composite key. A collection navigation can only be loaded through this collection route; the reference route rejects a collection relationship.
childQuery supplies the child source, so it can add the child's own filters,
ordering or per-parent paging; split loading honors every child-query shape. Modes, chunking, the
assignment rule, ordering and the stitching terminals are the same as for the explicit-key
overload. The declared-metadata form is SQL-only: the in-memory provider rejects it while the
parent command is constructed, before any SQL and before any plan-cache entry.
public EntityBuilder<TEntity> LoadWith<TChild>(Expression<Func<TEntity, ICollection<TChild>>> collection, Func<IDataContext, EntityBuilder<TChild>> childQuery, EagerLoadMode mode = EagerLoadMode.Default)
Parameters
collectionExpression<Func<TEntity, ICollection<TChild>>>The parent-side collection navigation to fill.
childQueryFunc<IDataContext, EntityBuilder<TChild>>Builds the child query from the data context that owns the parent query.
modeEagerLoadModeThe whole-builder eager-load mode; Default inherits the current choice.
Returns
- EntityBuilder<TEntity>
A copy of this builder carrying the eager-load declaration.
Type Parameters
TChildThe related entity type.
Exceptions
- ArgumentOutOfRangeException
modeis not a defined value.- InvalidOperationException
The navigation already carries an eager-load declaration on this builder.
- NotSupportedException
The selector is not a collection navigation, no relationship is declared for it, the declared relationship is not a collection relationship of
TChild, its key lists are structurally invalid, a different explicit mode is already active, or the context is the in-memory provider.
LoadWith<TChild>(Expression<Func<TEntity, TChild?>>, EagerLoadMode)
Declares the eager loading of a declared reference navigation without explicit key
selectors: the relationship is read from the mapping metadata — HasOne/HasOneToOne
(fluent) or [Relationship] — and its ordered key components are paired positionally, parent
component at position i with child component at position i.
The relationship is resolved and structurally validated when this method is called, so an undeclared navigation, a collection cardinality and malformed metadata are rejected before any SQL is generated and before any plan-cache entry exists. nextorm never infers a relationship from a naming convention, never matches key columns by name and never falls back to the first component of a composite key. A collection navigation can only be loaded through the collection route; this reference route rejects a collection relationship, including a many-to-many one.
One related row is assigned per parent: no matching row assigns null, and more
than one distinct full identity for the same parent throws
InvalidOperationException before any parent is mutated. A read-only navigation can
only be loaded when its current value already is the resolved row; otherwise it fails closed with
NotSupportedException. The child query is the context's ordinary
From<TChild>() source, so the related type's mapping and global filters apply; use the
childQuery overload to add the child's own filters or ordering. Modes, chunking, ordering and
the stitching terminals are the same as for the explicit-key overload, and a child page is rejected
because a per-parent top-N applies to a collection. The declared-metadata form is SQL-only: the
in-memory provider rejects it while the parent command is constructed, before any SQL and before
any plan-cache entry.
public EntityBuilder<TEntity> LoadWith<TChild>(Expression<Func<TEntity, TChild?>> reference, EagerLoadMode mode = EagerLoadMode.Default) where TChild : class
Parameters
referenceExpression<Func<TEntity, TChild>>The parent-side reference navigation to fill.
modeEagerLoadModeThe whole-builder eager-load mode; Default inherits the current choice.
Returns
- EntityBuilder<TEntity>
A copy of this builder carrying the eager-load declaration.
Type Parameters
TChildThe related entity type.
Exceptions
- ArgumentOutOfRangeException
modeis not a defined value.- InvalidOperationException
The navigation already carries an eager-load declaration on this builder, or more than one distinct related row matches a single parent.
- NotSupportedException
The selector is not a reference navigation, no relationship is declared for it, the declared relationship is not a reference relationship of
TChild, its key lists are structurally invalid, a different explicit mode is already active, the child query pages per parent, the navigation is read-only and would have to be written, or the context is the in-memory provider.
LoadWith<TChild>(Expression<Func<TEntity, TChild?>>, Func<IDataContext, EntityBuilder<TChild>>, EagerLoadMode)
Declares the eager loading of a declared reference navigation through a child query,
without explicit key selectors: the relationship is read from the mapping metadata —
HasOne/HasOneToOne (fluent) or [Relationship] — and its ordered key components
are paired positionally.
The relationship is resolved and structurally validated when this method is called, so an undeclared navigation, a collection cardinality and malformed metadata are rejected before any SQL is generated and before any plan-cache entry exists. nextorm never infers a relationship from a naming convention, never matches key columns by name and never falls back to the first component of a composite key. A collection navigation can only be loaded through the collection route; this reference route rejects a collection relationship, including a many-to-many one.
One related row is assigned per parent: no matching row assigns null, and more
than one distinct full identity for the same parent throws
InvalidOperationException before any parent is mutated. A read-only navigation can
only be loaded when its current value already is the resolved row; otherwise it fails closed with
NotSupportedException. childQuery can add the child's own filters
or ordering; a child page is rejected because a per-parent top-N applies to a collection. Modes,
chunking, ordering and the stitching terminals are the same as for the explicit-key overload. The
declared-metadata form is SQL-only: the in-memory provider rejects it while the parent command is
constructed, before any SQL and before any plan-cache entry.
public EntityBuilder<TEntity> LoadWith<TChild>(Expression<Func<TEntity, TChild?>> reference, Func<IDataContext, EntityBuilder<TChild>> childQuery, EagerLoadMode mode = EagerLoadMode.Default) where TChild : class
Parameters
referenceExpression<Func<TEntity, TChild>>The parent-side reference navigation to fill.
childQueryFunc<IDataContext, EntityBuilder<TChild>>Builds the child query from the data context that owns the parent query.
modeEagerLoadModeThe whole-builder eager-load mode; Default inherits the current choice.
Returns
- EntityBuilder<TEntity>
A copy of this builder carrying the eager-load declaration.
Type Parameters
TChildThe related entity type.
Exceptions
- ArgumentOutOfRangeException
modeis not a defined value.- InvalidOperationException
The navigation already carries an eager-load declaration on this builder, or more than one distinct related row matches a single parent.
- NotSupportedException
The selector is not a reference navigation, no relationship is declared for it, the declared relationship is not a reference relationship of
TChild, its key lists are structurally invalid, a different explicit mode is already active, the child query pages per parent, the navigation is read-only and would have to be written, or the context is the in-memory provider.
LoadWith<TChild, TKey>(Expression<Func<TEntity, ICollection<TChild>>>, Func<IDataContext, EntityBuilder<TChild>>, Expression<Func<TEntity, TKey>>, Expression<Func<TChild, TKey>>, EagerLoadMode)
Declares a split-query eager load for collection: after the parent query is
materialized, one extra child query per key chunk is executed to fetch the children, and they are
stitched onto the parents in memory (two round trips, never N+1). Only the stitching terminals
(ToList/ToListAsync and ToArray/ToArrayAsync) honor the declaration;
ToHashSet, ToDictionary, First, FirstOrDefault, Single*,
ToEnumerable, ToAsyncEnumerable and ToCommand() run the parent only and
do not load the collection, and Count/Any stay scalar without extra load queries.
The parent's current collection value is cleared and refilled when it is non-null; a null value is assigned a fresh list when the member is settable. A read-only member whose value is null is rejected with NotSupportedException. Every target is validated before the parents are mutated, so the rejection leaves no parent partially populated. The child order follows the child query's order.
A collection member may be declared only once: calling LoadWith twice for the same member
throws InvalidOperationException. Declare distinct members on the same builder to
load several collections.
mode selects the whole builder's loading strategy. Default
inherits the mode already chosen by an earlier LoadWith (split when none was); an explicit
SplitQuery or SingleQuery applies to every
declared collection, including one declared earlier. Repeating the same explicit mode is allowed,
but choosing a different explicit mode is rejected with NotSupportedException.
public EntityBuilder<TEntity> LoadWith<TChild, TKey>(Expression<Func<TEntity, ICollection<TChild>>> collection, Func<IDataContext, EntityBuilder<TChild>> childQuery, Expression<Func<TEntity, TKey>> parentKey, Expression<Func<TChild, TKey>> childKey, EagerLoadMode mode = EagerLoadMode.Default) where TKey : notnull
Parameters
collectionExpression<Func<TEntity, ICollection<TChild>>>The parent-side collection member to fill.
childQueryFunc<IDataContext, EntityBuilder<TChild>>Builds the child query from the data context that owns the parent query.
parentKeyExpression<Func<TEntity, TKey>>Selects the parent key used to match children.
childKeyExpression<Func<TChild, TKey>>Selects the child key used to match parents.
modeEagerLoadModeThe whole-builder eager-load mode; Default inherits the current choice (split when none was made).
Returns
- EntityBuilder<TEntity>
A copy of this builder carrying the eager-load declaration and the resolved mode.
Type Parameters
TChildThe child entity type.
TKeyThe non-nullable key type shared by the parent and child selectors. A null key value observed at runtime is skipped and never matches.
Exceptions
- InvalidOperationException
The collection member already carries an eager-load declaration on this builder.
- ArgumentOutOfRangeException
modeis not a defined value.- NotSupportedException
A different explicit mode is already active on this builder.
Offset(int)
Sets the number of leading rows to skip; zero starts from the first row.
public EntityBuilder<TEntity> Offset(int offset)
Parameters
offsetintThe number of rows to skip; must be non-negative.
Returns
- EntityBuilder<TEntity>
A builder with the new offset.
OrderBy(int)
Adds an ascending ordering key by 1-based output column index.
public EntityBuilder<TEntity> OrderBy(int columnIdx)
Parameters
columnIdxintThe 1-based result column index; must be greater than zero.
Returns
- EntityBuilder<TEntity>
A builder with the added ordering key.
OrderBy(int, NullsPosition)
Adds an ascending ordering key by 1-based output column index with the requested NULL placement.
public EntityBuilder<TEntity> OrderBy(int columnIdx, NullsPosition nullsPosition)
Parameters
columnIdxintThe 1-based result column index; must be greater than zero.
nullsPositionNullsPositionWhere SQL
NULLvalues are placed for this key.
Returns
- EntityBuilder<TEntity>
A builder with the added ordering key.
Exceptions
- ArgumentOutOfRangeException
nullsPositionis not a defined NullsPosition member.
OrderBy(int, OrderDirection)
Adds an ordering key by 1-based output column index.
public EntityBuilder<TEntity> OrderBy(int columnIdx, OrderDirection direction)
Parameters
columnIdxintThe 1-based result column index; must be greater than zero.
directionOrderDirectionAscending or descending.
Returns
- EntityBuilder<TEntity>
A builder with the added ordering key.
OrderBy(int, OrderDirection, NullsPosition)
Adds an ordering key by 1-based output column index with the given direction and NULL placement.
public EntityBuilder<TEntity> OrderBy(int columnIdx, OrderDirection direction, NullsPosition nullsPosition)
Parameters
columnIdxintThe 1-based result column index; must be greater than zero.
directionOrderDirectionAscending or descending.
nullsPositionNullsPositionWhere SQL
NULLvalues are placed for this key.
Returns
- EntityBuilder<TEntity>
A builder with the added ordering key.
Exceptions
- ArgumentOutOfRangeException
nullsPositionis not a defined NullsPosition member.
OrderBy(Expression<Func<TEntity, object?>>)
Adds an ascending ordering key by orderExp.
public EntityBuilder<TEntity> OrderBy(Expression<Func<TEntity, object?>> orderExp)
Parameters
orderExpExpression<Func<TEntity, object>>The key selector.
Returns
- EntityBuilder<TEntity>
A builder with the added ordering key.
OrderBy(Expression<Func<TEntity, object?>>, NullsPosition)
Adds an ascending ordering key by orderExp with the requested NULL placement.
Repeated calls append keys, so the existing order is preserved.
public EntityBuilder<TEntity> OrderBy(Expression<Func<TEntity, object?>> orderExp, NullsPosition nullsPosition)
Parameters
orderExpExpression<Func<TEntity, object>>The key selector.
nullsPositionNullsPositionWhere SQL
NULLvalues are placed for this key.
Returns
- EntityBuilder<TEntity>
A builder with the added ordering key.
Exceptions
- ArgumentOutOfRangeException
nullsPositionis not a defined NullsPosition member.
OrderBy(Expression<Func<TEntity, object?>>, OrderDirection)
Adds an ordering key. Repeated calls append keys, so the existing order is preserved.
public EntityBuilder<TEntity> OrderBy(Expression<Func<TEntity, object?>> orderExp, OrderDirection direction)
Parameters
orderExpExpression<Func<TEntity, object>>The key selector.
directionOrderDirectionAscending or descending.
Returns
- EntityBuilder<TEntity>
A builder with the added ordering key.
OrderBy(Expression<Func<TEntity, object?>>, OrderDirection, NullsPosition)
Adds an ordering key by orderExp with the given direction and NULL placement.
Repeated calls append keys, so the existing order is preserved.
public EntityBuilder<TEntity> OrderBy(Expression<Func<TEntity, object?>> orderExp, OrderDirection direction, NullsPosition nullsPosition)
Parameters
orderExpExpression<Func<TEntity, object>>The key selector.
directionOrderDirectionAscending or descending.
nullsPositionNullsPositionWhere SQL
NULLvalues are placed for this key.
Returns
- EntityBuilder<TEntity>
A builder with the added ordering key.
Exceptions
- ArgumentOutOfRangeException
nullsPositionis not a defined NullsPosition member.
OrderByDescending(int)
Adds a descending ordering key by 1-based output column index.
public EntityBuilder<TEntity> OrderByDescending(int columnIdx)
Parameters
columnIdxintThe 1-based result column index; must be greater than zero.
Returns
- EntityBuilder<TEntity>
A builder with the added ordering key.
OrderByDescending(int, NullsPosition)
Adds a descending ordering key by 1-based output column index with the requested NULL placement.
public EntityBuilder<TEntity> OrderByDescending(int columnIdx, NullsPosition nullsPosition)
Parameters
columnIdxintThe 1-based result column index; must be greater than zero.
nullsPositionNullsPositionWhere SQL
NULLvalues are placed for this key.
Returns
- EntityBuilder<TEntity>
A builder with the added ordering key.
Exceptions
- ArgumentOutOfRangeException
nullsPositionis not a defined NullsPosition member.
OrderByDescending(Expression<Func<TEntity, object?>>)
Adds a descending ordering key by orderExp.
public EntityBuilder<TEntity> OrderByDescending(Expression<Func<TEntity, object?>> orderExp)
Parameters
orderExpExpression<Func<TEntity, object>>The key selector.
Returns
- EntityBuilder<TEntity>
A builder with the added ordering key.
OrderByDescending(Expression<Func<TEntity, object?>>, NullsPosition)
Adds a descending ordering key by orderExp with the requested NULL placement.
public EntityBuilder<TEntity> OrderByDescending(Expression<Func<TEntity, object?>> orderExp, NullsPosition nullsPosition)
Parameters
orderExpExpression<Func<TEntity, object>>The key selector.
nullsPositionNullsPositionWhere SQL
NULLvalues are placed for this key.
Returns
- EntityBuilder<TEntity>
A builder with the added ordering key.
Exceptions
- ArgumentOutOfRangeException
nullsPositionis not a defined NullsPosition member.
OuterApply(string, Action<JoinOptions>?)
Adds an OUTER APPLY over the table named table without an explicit source.
public JoinedEntityBuilder<TEntity, TableAlias> OuterApply(string table, Action<JoinOptions>? options = null)
Parameters
tablestringThe physical table name of the joined source.
optionsAction<JoinOptions>Optional per-join configuration; forwarded unchanged.
Returns
- JoinedEntityBuilder<TEntity, TableAlias>
A builder over the projection extended with TableAlias.
Remarks
A null, empty, or whitespace-only table is rejected at the call site with ArgumentNullException / ArgumentException (ParamName == "table"), matching the explicit ctx.From(table) form.
OuterApply<TJoinEntity>(Cte<TJoinEntity>)
Applies the typed CTE cte with OUTER APPLY.
public JoinedEntityBuilder<TEntity, TJoinEntity> OuterApply<TJoinEntity>(Cte<TJoinEntity> cte)
Parameters
cteCte<TJoinEntity>The CTE descriptor, converted with this builder's context.
Returns
- JoinedEntityBuilder<TEntity, TJoinEntity>
A builder over the applied projection.
Type Parameters
TJoinEntityThe CTE's projection type.
Exceptions
- ArgumentNullException
cteis null.
OuterApply<TJoinEntity>(Cte<TJoinEntity>, Action<JoinOptions>?)
Applies the typed CTE cte with OUTER APPLY and per-join options.
public JoinedEntityBuilder<TEntity, TJoinEntity> OuterApply<TJoinEntity>(Cte<TJoinEntity> cte, Action<JoinOptions>? options)
Parameters
cteCte<TJoinEntity>The CTE descriptor, converted with this builder's context.
optionsAction<JoinOptions>Per-join configuration.
Returns
- JoinedEntityBuilder<TEntity, TJoinEntity>
A builder over the applied projection.
Type Parameters
TJoinEntityThe CTE's projection type.
Exceptions
- ArgumentNullException
cteis null.
OuterApply<TJoinEntity>(EntityBuilder<TJoinEntity>, Action<JoinOptions>?)
Applies _ to every left-hand row, preserving left-hand rows with an empty
result (OUTER APPLY / LEFT JOIN LATERAL ... ON true). There is no ON condition.
public JoinedEntityBuilder<TEntity, TJoinEntity> OuterApply<TJoinEntity>(EntityBuilder<TJoinEntity> _, Action<JoinOptions>? options = null)
Parameters
_EntityBuilder<TJoinEntity>The builder for the applied entity; only its source is used.
optionsAction<JoinOptions>Optional per-join configuration; see CrossApply<TJoinEntity>(EntityBuilder<TJoinEntity>, Action<JoinOptions>?).
Returns
- JoinedEntityBuilder<TEntity, TJoinEntity>
A builder over the applied projection.
Type Parameters
TJoinEntity
OuterApply<TJoinEntity>(QueryCommand<TJoinEntity>, Action<JoinOptions>?)
Applies a derived query to every left-hand row, preserving left-hand rows with an empty result
(OUTER APPLY).
public JoinedEntityBuilder<TEntity, TJoinEntity> OuterApply<TJoinEntity>(QueryCommand<TJoinEntity> query, Action<JoinOptions>? options = null)
Parameters
queryQueryCommand<TJoinEntity>optionsAction<JoinOptions>
Returns
- JoinedEntityBuilder<TEntity, TJoinEntity>
Type Parameters
TJoinEntity
OuterApply<TJoinEntity>(Action<JoinOptions>?)
Adds an OUTER APPLY over TJoinEntity without an explicit source; TJoinEntity is resolved through this builder's context (From<TJoinEntity>()) and forwarded to the source-explicit overload.
public JoinedEntityBuilder<TEntity, TJoinEntity> OuterApply<TJoinEntity>(Action<JoinOptions>? options = null)
Parameters
optionsAction<JoinOptions>Optional per-join configuration; forwarded unchanged to the source-explicit overload.
Returns
- JoinedEntityBuilder<TEntity, TJoinEntity>
A builder over the projection extended with
TJoinEntity.
Type Parameters
TJoinEntityThe entity type of the joined table.
OuterApply<TJoinEntity>(Expression<Func<TEntity, EntityBuilder<TJoinEntity>>>, Action<JoinOptions>?)
Applies a correlated derived query to every left-hand row, preserving left-hand rows with an
empty result (OUTER APPLY / LEFT JOIN LATERAL ... ON true). source
receives the left-hand row, so the query it builds may reference its columns.
public JoinedEntityBuilder<TEntity, TJoinEntity> OuterApply<TJoinEntity>(Expression<Func<TEntity, EntityBuilder<TJoinEntity>>> source, Action<JoinOptions>? options = null)
Parameters
sourceExpression<Func<TEntity, EntityBuilder<TJoinEntity>>>optionsAction<JoinOptions>
Returns
- JoinedEntityBuilder<TEntity, TJoinEntity>
Type Parameters
TJoinEntity
OuterApply<TJoinEntity>(Expression<Func<TEntity, QueryCommand<TJoinEntity>>>, Action<JoinOptions>?)
Applies a correlated derived query to every left-hand row, preserving left-hand rows with an
empty result (OUTER APPLY / LEFT JOIN LATERAL ... ON true). source
receives the left-hand row, so the query it builds may reference its columns.
public JoinedEntityBuilder<TEntity, TJoinEntity> OuterApply<TJoinEntity>(Expression<Func<TEntity, QueryCommand<TJoinEntity>>> source, Action<JoinOptions>? options = null)
Parameters
sourceExpression<Func<TEntity, QueryCommand<TJoinEntity>>>optionsAction<JoinOptions>
Returns
- JoinedEntityBuilder<TEntity, TJoinEntity>
Type Parameters
TJoinEntity
Page(int, int)
Sets both the page size and the start position in a single call.
public EntityBuilder<TEntity> Page(int limit, int offset)
Parameters
limitintThe page size; must be non-negative.
offsetintThe number of leading rows to skip; must be non-negative.
Returns
- EntityBuilder<TEntity>
A builder with the new limit and offset.
RightJoin(string, Expression<Func<TEntity, TableAlias, bool>>, Action<JoinOptions>?)
Adds a RIGHT JOIN over the table named table without an explicit source.
public JoinedEntityBuilder<TEntity, TableAlias> RightJoin(string table, Expression<Func<TEntity, TableAlias, bool>> joinCondition, Action<JoinOptions>? options = null)
Parameters
tablestringThe physical table name of the joined source.
joinConditionExpression<Func<TEntity, TableAlias, bool>>A predicate relating the current entity to the joined TableAlias row.
optionsAction<JoinOptions>Optional per-join configuration; forwarded unchanged.
Returns
- JoinedEntityBuilder<TEntity, TableAlias>
A builder over the projection extended with TableAlias.
Remarks
A null joinCondition is accepted and renders no ON clause, matching the explicit form over ctx.From(table).
RightJoin<TJoinEntity>(Cte<TJoinEntity>, Expression<Func<TEntity, TJoinEntity, bool>>)
Adds a right outer join over the typed CTE cte.
public JoinedEntityBuilder<TEntity, TJoinEntity> RightJoin<TJoinEntity>(Cte<TJoinEntity> cte, Expression<Func<TEntity, TJoinEntity, bool>> joinCondition)
Parameters
cteCte<TJoinEntity>The CTE descriptor, converted with this builder's context.
joinConditionExpression<Func<TEntity, TJoinEntity, bool>>The join predicate over the two entities.
Returns
- JoinedEntityBuilder<TEntity, TJoinEntity>
A builder over the joined projection.
Type Parameters
TJoinEntityThe CTE's projection type.
Exceptions
- ArgumentNullException
cteorjoinConditionis null.
RightJoin<TJoinEntity>(Cte<TJoinEntity>, Expression<Func<TEntity, TJoinEntity, bool>>, Action<JoinOptions>?)
Adds a right outer join over the typed CTE cte with per-join options.
public JoinedEntityBuilder<TEntity, TJoinEntity> RightJoin<TJoinEntity>(Cte<TJoinEntity> cte, Expression<Func<TEntity, TJoinEntity, bool>> joinCondition, Action<JoinOptions>? options)
Parameters
cteCte<TJoinEntity>The CTE descriptor, converted with this builder's context.
joinConditionExpression<Func<TEntity, TJoinEntity, bool>>The join predicate over the two entities.
optionsAction<JoinOptions>Per-join configuration.
Returns
- JoinedEntityBuilder<TEntity, TJoinEntity>
A builder over the joined projection.
Type Parameters
TJoinEntityThe CTE's projection type.
Exceptions
- ArgumentNullException
cteorjoinConditionis null.
RightJoin<TJoinEntity>(EntityBuilder<TJoinEntity>, Expression<Func<TEntity, TJoinEntity, bool>>, Action<JoinOptions>?)
Adds a right outer join: every right-hand row is kept, and left-hand columns are NULL
when there is no match.
public JoinedEntityBuilder<TEntity, TJoinEntity> RightJoin<TJoinEntity>(EntityBuilder<TJoinEntity> _, Expression<Func<TEntity, TJoinEntity, bool>> joinCondition, Action<JoinOptions>? options = null)
Parameters
_EntityBuilder<TJoinEntity>The builder for the joined entity; only its source is used.
joinConditionExpression<Func<TEntity, TJoinEntity, bool>>The join predicate over the two entities.
optionsAction<JoinOptions>Optional per-join configuration, for example
j => j.Global()orj => j.WithStrictness(JoinStrictness.Any).
Returns
- JoinedEntityBuilder<TEntity, TJoinEntity>
A builder over the joined projection.
Type Parameters
TJoinEntity
RightJoin<TJoinEntity>(QueryCommand<TJoinEntity>, Expression<Func<TEntity, TJoinEntity, bool>>, Action<JoinOptions>?)
Adds a right outer join to the derived query: every right-hand row is kept,
and left-hand columns are NULL when there is no match.
public JoinedEntityBuilder<TEntity, TJoinEntity> RightJoin<TJoinEntity>(QueryCommand<TJoinEntity> query, Expression<Func<TEntity, TJoinEntity, bool>> joinCondition, Action<JoinOptions>? options = null)
Parameters
queryQueryCommand<TJoinEntity>The derived query to join.
joinConditionExpression<Func<TEntity, TJoinEntity, bool>>The join predicate over the two entities.
optionsAction<JoinOptions>Optional per-join configuration, for example
j => j.Global()orj => j.WithStrictness(JoinStrictness.Any).
Returns
- JoinedEntityBuilder<TEntity, TJoinEntity>
A builder over the joined projection.
Type Parameters
TJoinEntity
RightJoin<TJoinEntity>(Expression<Func<TEntity, TJoinEntity, bool>>, Action<JoinOptions>?)
Adds a RIGHT JOIN over TJoinEntity without an explicit source; TJoinEntity is resolved through this builder's context (From<TJoinEntity>()) and forwarded to the source-explicit overload.
public JoinedEntityBuilder<TEntity, TJoinEntity> RightJoin<TJoinEntity>(Expression<Func<TEntity, TJoinEntity, bool>> joinCondition, Action<JoinOptions>? options = null)
Parameters
joinConditionExpression<Func<TEntity, TJoinEntity, bool>>A predicate relating the current projection to the joined entity.
optionsAction<JoinOptions>Optional per-join configuration; forwarded unchanged to the source-explicit overload.
Returns
- JoinedEntityBuilder<TEntity, TJoinEntity>
A builder over the projection extended with
TJoinEntity.
Type Parameters
TJoinEntityThe entity type of the joined table.
Exceptions
- ArgumentNullException
joinConditionis null.
SelectMany<TCollection>(Expression<Func<TEntity, IEnumerable<TCollection>>>)
Flattens the sequence produced by collectionSelector for every row of this
query (source.SelectMany(...)), yielding the selected elements.
Supported by the InMemoryDataContext only; SQL providers throw NotSupportedException.
public EntityBuilder<TCollection> SelectMany<TCollection>(Expression<Func<TEntity, IEnumerable<TCollection>>> collectionSelector)
Parameters
collectionSelectorExpression<Func<TEntity, IEnumerable<TCollection>>>
Returns
- EntityBuilder<TCollection>
Type Parameters
TCollection
SelectMany<TCollection, TResult>(Expression<Func<TEntity, IEnumerable<TCollection>>>, Expression<Func<TEntity, TCollection, TResult>>)
Flattens the sequence produced by collectionSelector for every row of this
query and projects each pair with resultSelector.
Supported by the InMemoryDataContext only; SQL providers throw NotSupportedException.
public EntityBuilder<TResult> SelectMany<TCollection, TResult>(Expression<Func<TEntity, IEnumerable<TCollection>>> collectionSelector, Expression<Func<TEntity, TCollection, TResult>> resultSelector)
Parameters
collectionSelectorExpression<Func<TEntity, IEnumerable<TCollection>>>resultSelectorExpression<Func<TEntity, TCollection, TResult>>
Returns
- EntityBuilder<TResult>
Type Parameters
TCollectionTResult
SelectWhereMaxOld<TValue>(Expression<Func<TEntity, TValue>>, ExtremeRowTies, Expression<Func<TEntity, object?>>?)
Selects the row(s) with the maximum valueSelector value, optionally per
groupBy group. Requires a dialect that supports it (see
SupportsSelectWhereMinMax).
public EntityBuilder<TEntity> SelectWhereMaxOld<TValue>(Expression<Func<TEntity, TValue>> valueSelector, ExtremeRowTies ties = ExtremeRowTies.One, Expression<Func<TEntity, object?>>? groupBy = null)
Parameters
valueSelectorExpression<Func<TEntity, TValue>>The value whose maximum is compared.
tiesExtremeRowTiesWhether to keep a single row or every tied row.
groupByExpression<Func<TEntity, object>>Optional grouping key;
nullselects across the whole result.
Returns
- EntityBuilder<TEntity>
Type Parameters
TValueThe value type compared for the extremum.
SelectWhereMaxOld<TValue, TResult>(Expression<Func<TEntity, TValue>>, Expression<Func<TEntity, TResult>>, ExtremeRowTies, Expression<Func<TEntity, object?>>?)
Selects the row(s) with the maximum valueSelector value and projects each with
projection, optionally per groupBy group. Requires a dialect
that supports it (see SupportsSelectWhereMinMax).
public QueryCommand<TResult> SelectWhereMaxOld<TValue, TResult>(Expression<Func<TEntity, TValue>> valueSelector, Expression<Func<TEntity, TResult>> projection, ExtremeRowTies ties = ExtremeRowTies.One, Expression<Func<TEntity, object?>>? groupBy = null)
Parameters
valueSelectorExpression<Func<TEntity, TValue>>The value whose maximum is compared.
projectionExpression<Func<TEntity, TResult>>The projection applied to the surviving row(s).
tiesExtremeRowTiesWhether to keep a single row or every tied row.
groupByExpression<Func<TEntity, object>>Optional grouping key;
nullselects across the whole result.
Returns
- QueryCommand<TResult>
Type Parameters
TValueThe value type compared for the extremum.
TResultThe projection type.
SelectWhereMinOld<TValue>(Expression<Func<TEntity, TValue>>, ExtremeRowTies, Expression<Func<TEntity, object?>>?)
Selects the row(s) with the minimum valueSelector value, optionally per
groupBy group. Requires a dialect that supports it (see
SupportsSelectWhereMinMax).
public EntityBuilder<TEntity> SelectWhereMinOld<TValue>(Expression<Func<TEntity, TValue>> valueSelector, ExtremeRowTies ties = ExtremeRowTies.One, Expression<Func<TEntity, object?>>? groupBy = null)
Parameters
valueSelectorExpression<Func<TEntity, TValue>>The value whose minimum is compared.
tiesExtremeRowTiesWhether to keep a single row or every tied row.
groupByExpression<Func<TEntity, object>>Optional grouping key;
nullselects across the whole result.
Returns
- EntityBuilder<TEntity>
Type Parameters
TValueThe value type compared for the extremum.
SelectWhereMinOld<TValue, TResult>(Expression<Func<TEntity, TValue>>, Expression<Func<TEntity, TResult>>, ExtremeRowTies, Expression<Func<TEntity, object?>>?)
Selects the row(s) with the minimum valueSelector value and projects each with
projection, optionally per groupBy group. Requires a dialect
that supports it (see SupportsSelectWhereMinMax).
public QueryCommand<TResult> SelectWhereMinOld<TValue, TResult>(Expression<Func<TEntity, TValue>> valueSelector, Expression<Func<TEntity, TResult>> projection, ExtremeRowTies ties = ExtremeRowTies.One, Expression<Func<TEntity, object?>>? groupBy = null)
Parameters
valueSelectorExpression<Func<TEntity, TValue>>The value whose minimum is compared.
projectionExpression<Func<TEntity, TResult>>The projection applied to the surviving row(s).
tiesExtremeRowTiesWhether to keep a single row or every tied row.
groupByExpression<Func<TEntity, object>>Optional grouping key;
nullselects across the whole result.
Returns
- QueryCommand<TResult>
Type Parameters
TValueThe value type compared for the extremum.
TResultThe projection type.
Select<TResult>(Expression<Func<TEntity, TResult>>)
Projects each row with exp and creates the SELECT command for the query,
carrying every modifier set on this builder.
public QueryCommand<TResult> Select<TResult>(Expression<Func<TEntity, TResult>> exp)
Parameters
expExpression<Func<TEntity, TResult>>The projection expression.
Returns
- QueryCommand<TResult>
The command that produces
TResultrows.
Type Parameters
TResultThe projection type produced by
exp.
ThenBy(int)
Adds an ascending secondary ordering key by 1-based output column index. The key is appended after every existing key; it never replaces one.
public EntityBuilder<TEntity> ThenBy(int columnIdx)
Parameters
columnIdxintThe 1-based result column index; must be greater than zero.
Returns
- EntityBuilder<TEntity>
A builder with the appended ordering key.
ThenBy(int, NullsPosition)
Adds an ascending secondary ordering key by 1-based output column index with the requested NULL placement. The key is appended after every existing key; it never replaces one.
public EntityBuilder<TEntity> ThenBy(int columnIdx, NullsPosition nullsPosition)
Parameters
columnIdxintThe 1-based result column index; must be greater than zero.
nullsPositionNullsPositionWhere SQL
NULLvalues are placed for this key.
Returns
- EntityBuilder<TEntity>
A builder with the appended ordering key.
Exceptions
- ArgumentOutOfRangeException
nullsPositionis not a defined NullsPosition member.
ThenBy(int, OrderDirection)
Adds a secondary ordering key by 1-based output column index with the given direction. The key is appended after every existing key; it never replaces one.
public EntityBuilder<TEntity> ThenBy(int columnIdx, OrderDirection direction)
Parameters
columnIdxintThe 1-based result column index; must be greater than zero.
directionOrderDirectionAscending or descending.
Returns
- EntityBuilder<TEntity>
A builder with the appended ordering key.
ThenBy(int, OrderDirection, NullsPosition)
Adds a secondary ordering key by 1-based output column index with the given direction and NULL placement. The key is appended after every existing key; it never replaces one.
public EntityBuilder<TEntity> ThenBy(int columnIdx, OrderDirection direction, NullsPosition nullsPosition)
Parameters
columnIdxintThe 1-based result column index; must be greater than zero.
directionOrderDirectionAscending or descending.
nullsPositionNullsPositionWhere SQL
NULLvalues are placed for this key.
Returns
- EntityBuilder<TEntity>
A builder with the appended ordering key.
Exceptions
- ArgumentOutOfRangeException
nullsPositionis not a defined NullsPosition member.
ThenBy(Expression<Func<TEntity, object?>>)
Adds an ascending secondary ordering key by orderExp. The key is appended after
every existing key; it never replaces one.
public EntityBuilder<TEntity> ThenBy(Expression<Func<TEntity, object?>> orderExp)
Parameters
orderExpExpression<Func<TEntity, object>>The key selector.
Returns
- EntityBuilder<TEntity>
A builder with the appended ordering key.
ThenBy(Expression<Func<TEntity, object?>>, NullsPosition)
Adds an ascending secondary ordering key by orderExp with the requested NULL
placement. The key is appended after every existing key; it never replaces one.
public EntityBuilder<TEntity> ThenBy(Expression<Func<TEntity, object?>> orderExp, NullsPosition nullsPosition)
Parameters
orderExpExpression<Func<TEntity, object>>The key selector.
nullsPositionNullsPositionWhere SQL
NULLvalues are placed for this key.
Returns
- EntityBuilder<TEntity>
A builder with the appended ordering key.
Exceptions
- ArgumentOutOfRangeException
nullsPositionis not a defined NullsPosition member.
ThenBy(Expression<Func<TEntity, object?>>, OrderDirection)
Adds a secondary ordering key by orderExp with the given direction. The key is
appended after every existing key; it never replaces one.
public EntityBuilder<TEntity> ThenBy(Expression<Func<TEntity, object?>> orderExp, OrderDirection direction)
Parameters
orderExpExpression<Func<TEntity, object>>The key selector.
directionOrderDirectionAscending or descending.
Returns
- EntityBuilder<TEntity>
A builder with the appended ordering key.
ThenBy(Expression<Func<TEntity, object?>>, OrderDirection, NullsPosition)
Adds a secondary ordering key by orderExp with the given direction and NULL
placement. The key is appended after every existing key; it never replaces one.
public EntityBuilder<TEntity> ThenBy(Expression<Func<TEntity, object?>> orderExp, OrderDirection direction, NullsPosition nullsPosition)
Parameters
orderExpExpression<Func<TEntity, object>>The key selector.
directionOrderDirectionAscending or descending.
nullsPositionNullsPositionWhere SQL
NULLvalues are placed for this key.
Returns
- EntityBuilder<TEntity>
A builder with the appended ordering key.
Exceptions
- ArgumentOutOfRangeException
nullsPositionis not a defined NullsPosition member.
ThenByDescending(int)
Adds a descending secondary ordering key by 1-based output column index. The key is appended after every existing key; it never replaces one.
public EntityBuilder<TEntity> ThenByDescending(int columnIdx)
Parameters
columnIdxintThe 1-based result column index; must be greater than zero.
Returns
- EntityBuilder<TEntity>
A builder with the appended ordering key.
ThenByDescending(int, NullsPosition)
Adds a descending secondary ordering key by 1-based output column index with the requested NULL placement. The key is appended after every existing key; it never replaces one.
public EntityBuilder<TEntity> ThenByDescending(int columnIdx, NullsPosition nullsPosition)
Parameters
columnIdxintThe 1-based result column index; must be greater than zero.
nullsPositionNullsPositionWhere SQL
NULLvalues are placed for this key.
Returns
- EntityBuilder<TEntity>
A builder with the appended ordering key.
Exceptions
- ArgumentOutOfRangeException
nullsPositionis not a defined NullsPosition member.
ThenByDescending(Expression<Func<TEntity, object?>>)
Adds a descending secondary ordering key by orderExp. The key is appended after
every existing key; it never replaces one.
public EntityBuilder<TEntity> ThenByDescending(Expression<Func<TEntity, object?>> orderExp)
Parameters
orderExpExpression<Func<TEntity, object>>The key selector.
Returns
- EntityBuilder<TEntity>
A builder with the appended ordering key.
ThenByDescending(Expression<Func<TEntity, object?>>, NullsPosition)
Adds a descending secondary ordering key by orderExp with the requested NULL
placement. The key is appended after every existing key; it never replaces one.
public EntityBuilder<TEntity> ThenByDescending(Expression<Func<TEntity, object?>> orderExp, NullsPosition nullsPosition)
Parameters
orderExpExpression<Func<TEntity, object>>The key selector.
nullsPositionNullsPositionWhere SQL
NULLvalues are placed for this key.
Returns
- EntityBuilder<TEntity>
A builder with the appended ordering key.
Exceptions
- ArgumentOutOfRangeException
nullsPositionis not a defined NullsPosition member.
ToCommand()
Creates a SELECT command over the entity type without a custom projection, carrying every modifier set on this builder.
public QueryCommand<TEntity> ToCommand()
Returns
- QueryCommand<TEntity>
The command that produces
TEntityrows.
Where(Expression<Func<TEntity, bool>>)
Adds condition to the WHERE clause. A repeated call combines the predicates
with and. Returns a new builder; the current one is unchanged.
public EntityBuilder<TEntity> Where(Expression<Func<TEntity, bool>> condition)
Parameters
conditionExpression<Func<TEntity, bool>>The predicate each row must satisfy.
Returns
- EntityBuilder<TEntity>
A builder with the added predicate.
Window(string, Expression<Func<TEntity, object?>>[]?, NamedWindowOrderKey[]?, WindowFrame?)
Declares a named window w AS (PARTITION BY ... ORDER BY ... frame) on this query. Window
functions reference it with Over("w"); every declared window renders in a single
WINDOW clause after GROUP BY/HAVING. Requires a dialect that supports named
windows (see SupportsNamedWindows). Declare windows after any join, on
the final builder.
public EntityBuilder<TEntity> Window(string name, Expression<Func<TEntity, object?>>[]? partitionBy = null, NamedWindowOrderKey[]? orderBy = null, WindowFrame? frame = null)
Parameters
namestringThe window name (a simple SQL identifier).
partitionByExpression<Func<TEntity, object>>[]Optional
PARTITION BYkey expressions.orderByNamedWindowOrderKey[]Optional
ORDER BYkeys, built with Asc(Expression<Func<TEntity, object?>>) or Desc(Expression<Func<TEntity, object?>>).frameWindowFrameOptional frame.
Returns
- EntityBuilder<TEntity>
WithCommandTimeout(int)
Overrides the command timeout in seconds for the commands this builder creates: it takes
precedence over the context default set with DataContextBuilder.UseCommandTimeout. A value
of zero or less means the provider default. The override is part of the plan-cache key, so two
otherwise identical queries with different timeouts do not share a cached command.
public EntityBuilder<TEntity> WithCommandTimeout(int seconds)
Parameters
secondsintThe command timeout in seconds; zero or less uses the provider default.
Returns
- EntityBuilder<TEntity>
A builder with the override applied.
WithComponent(IQueryComponent)
Attaches a query component to this builder. Components with the same slot replace the previous value in place; the builder is not mutated.
public EntityBuilder<TEntity> WithComponent(IQueryComponent component)
Parameters
componentIQueryComponentThe component to attach.
Returns
- EntityBuilder<TEntity>
A new builder with the component attached.
Exceptions
- ArgumentNullException
componentis null.
WithDatabase(string)
Qualifies the primary table with database for this query only
(database.schema.table on SQL Server, database.table on MySQL/MariaDB/ClickHouse,
an attached database on SQLite). Requires a provider that opted into
SupportsCrossDatabase.
public EntityBuilder<TEntity> WithDatabase(string database)
Parameters
databasestringThe database name to render before the table.
Returns
- EntityBuilder<TEntity>
A builder with the override applied.
WithKeywordCase(KeywordCase)
Overrides the letter case in which the SQL keywords of the commands this builder creates are
emitted (see DataContextBuilder.UseKeywordCase for the context default).
Upper renders SELECT ... FROM ...; identifiers, string literals,
function names, type names and raw SQL are never affected.
public EntityBuilder<TEntity> WithKeywordCase(KeywordCase keywordCase = KeywordCase.Upper)
Parameters
keywordCaseKeywordCaseThe keyword case to apply.
Returns
- EntityBuilder<TEntity>
A builder with the override applied.
WithNamingConvention(INamingConvention?)
Overrides the naming convention applied to auto-derived table/column names for the commands
this builder creates (see DataContextBuilder.UseNamingConvention for the context default).
public EntityBuilder<TEntity> WithNamingConvention(INamingConvention? convention)
Parameters
conventionINamingConvention
Returns
- EntityBuilder<TEntity>
WithQuotedIdentifiers(bool)
Overrides identifier quoting for the commands this builder creates: when
value is true, physical table and column names are quoted with the
provider's delimiter ("id" on PostgreSQL/SQLite, [id] on SQL Server,
`id` on MySQL/MariaDB/ClickHouse); when false, names are emitted verbatim.
Without a call the command inherits the context default set with
DataContextBuilder.UseQuotedIdentifiers.
public EntityBuilder<TEntity> WithQuotedIdentifiers(bool value = true)
Parameters
valuebool
Returns
- EntityBuilder<TEntity>
WithSchema(string)
Qualifies the primary table with schema for this query only, for example
From<IOrder>().WithSchema("sales") rendering sales.orders. Requires a provider
that can render a schema qualifier (see MakeQualifiedTableName(string?, string?, string?, string)).
public EntityBuilder<TEntity> WithSchema(string schema)
Parameters
schemastringThe schema name to render before the table.
Returns
- EntityBuilder<TEntity>
A builder with the override applied.
WithServer(string)
Qualifies the primary table with a linked server for this query only
(server.database.schema.table). Only SQL Server opted into
SupportsLinkedServer; every other provider rejects the override with
NotSupportedException.
public EntityBuilder<TEntity> WithServer(string server)
Parameters
serverstringThe linked server name to render before the table.
Returns
- EntityBuilder<TEntity>
A builder with the override applied.
WithTableExpression(string)
Replaces the primary table access with the raw SQL sql rendered as a derived
source ((sql) AS alias) for this query only. The mapped entity's columns are read from the
expression's result set. The fragment is emitted verbatim, so pass only trusted SQL (the caller
owns validity and injection safety, as with WithSql). Cannot be combined with a
table-name/schema/database/server override. SQL providers only.
public EntityBuilder<TEntity> WithTableExpression(string sql)
Parameters
sqlstringThe raw SQL expression to use as the table source.
Returns
- EntityBuilder<TEntity>
A builder with the source replaced.
WithTableName(string)
Overrides the physical table name of the primary source for this query only, for example
From<IOrder>().WithTableName("orders_archive"). The mapped entity (and its columns) is
unchanged, and other queries are unaffected. The name is emitted verbatim, or quoted when
identifier quoting is enabled (see WithQuotedIdentifiers(bool)).
public EntityBuilder<TEntity> WithTableName(string name)
Parameters
namestringThe table name to render instead of the mapped one.
Returns
- EntityBuilder<TEntity>
A builder with the override applied.
WithTablesInScopeHint(params string[])
Attaches hints to every physical table in the query's scope: on SQL Server each table (the
primary source and every joined table) gets a WITH (hint, ...) suffix; on
PostgreSQL/MySQL/MariaDB the hints are folded into the statement-level /*+ ... */ comment.
A dialect that supports neither rejects the command with NotSupportedException.
The hints are emitted verbatim, so only use trusted values.
public EntityBuilder<TEntity> WithTablesInScopeHint(params string[] hints)
Parameters
hintsstring[]The hint texts; at least one non-empty.
Returns
- EntityBuilder<TEntity>
A builder with the tables-in-scope hints applied.
Exceptions
- ArgumentException
No non-empty hint was supplied.
WithTag(string?)
Attaches a query tag to the commands this builder creates. The tag is rendered as a block comment
(/* tag */) immediately after the SELECT keyword on every SQL provider, so the
statement is identifiable in logs, profilers and server-side query stores. It is not an optimizer
hint (use Hint(params string[]) for that). Passing a new tag
returns a new builder; null or an empty string clears it. The tag is part of the plan key.
public EntityBuilder<TEntity> WithTag(string? tag)
Parameters
tagstringThe tag text to render, or
nullto clear the tag.
Returns
- EntityBuilder<TEntity>
A builder with the tag applied.
WithTies()
Marks the page request as WITH TIES: the result keeps every row tied with the last row of
the page by the ORDER BY. Requires a positive page limit and a dialect that supports it
(see SupportsWithTies). Cannot be combined with Distinct()
or DistinctOn: this combination is rejected during SQL generation with
BuildSqlCommandException; validation is not performed by the WithTies
fluent call itself.
public EntityBuilder<TEntity> WithTies()
Returns
- EntityBuilder<TEntity>
WithUppercaseKeywords(bool)
Convenience form of WithKeywordCase(KeywordCase): enables (value is
true) or disables upper-case SQL keywords for the commands this builder creates.
public EntityBuilder<TEntity> WithUppercaseKeywords(bool value = true)
Parameters
Returns
- EntityBuilder<TEntity>
A builder with the override applied.
Operators
implicit operator QueryCommand(EntityBuilder<TEntity>)
Implicitly converts the builder to its untyped command, so a builder can be passed where a QueryCommand is expected.
public static implicit operator QueryCommand(EntityBuilder<TEntity> builder)
Parameters
builderEntityBuilder<TEntity>The builder to convert.
Returns
- QueryCommand
The command built by ToCommand().
implicit operator QueryCommand<TEntity>(EntityBuilder<TEntity>)
Implicitly converts the builder to its command, so a builder can be passed where a QueryCommand<TResult> is expected.
public static implicit operator QueryCommand<TEntity>(EntityBuilder<TEntity> builder)
Parameters
builderEntityBuilder<TEntity>The builder to convert.
Returns
- QueryCommand<TEntity>
The command built by ToCommand().