Class JoinOptions
Per-join options applied while the join is declared, through the trailing
Action<JoinOptions> parameter of the Join/LeftJoin/RightJoin/
FullJoin/SemiJoin/AntiJoin/PasteJoin/CrossJoin/CrossApply/
OuterApply and JoinInto overloads
(for example a.Join(b, (x, y) => x.Id == y.Id, j => j.WithStrictness(JoinStrictness.Any))).
The values are copied into the resulting join, so the options object is not retained. The raw
named-table (TableAlias) CrossJoin/CrossApply/OuterApply overloads take
no options: those joins cannot carry the modifiers described here.
public sealed class JoinOptions
- Inheritance
-
JoinOptions
- Inherited Members
- Extension Methods
Methods
ForShare()
Locks the selected rows of this join's physical source in shared mode until the transaction ends,
blocking while a locked row is held by another transaction. On PostgreSQL/MySQL it renders a
targeted FOR SHARE OF <alias> clause; on SQL Server it applies the holdlock
table hint to this join's table only. Requires a dialect whose lock renderer reports
SupportsSourceLocks.
public JoinOptions ForShare()
Returns
- JoinOptions
This instance, to allow chaining.
ForShare(LockWaitMode)
Locks the selected rows of this join's physical source in shared mode until the transaction ends, with the requested wait behaviour for rows already locked by another transaction. Requires a dialect whose lock renderer reports SupportsSourceLocks.
public JoinOptions ForShare(LockWaitMode wait)
Parameters
waitLockWaitModeHow to react to a row already locked by another transaction.
Returns
- JoinOptions
This instance, to allow chaining.
ForUpdate()
Locks the selected rows of this join's physical source exclusively until the transaction ends,
blocking while a locked row is held by another transaction. On PostgreSQL/MySQL it renders a
targeted FOR UPDATE OF <alias> clause; on SQL Server it applies the updlock
table hint to this join's table only. Requires a dialect whose lock renderer reports
SupportsSourceLocks; a dialect without it (for example MariaDB)
rejects the command with NotSupportedException.
public JoinOptions ForUpdate()
Returns
- JoinOptions
This instance, to allow chaining.
ForUpdate(LockWaitMode)
Locks the selected rows of this join's physical source exclusively until the transaction ends, with the requested wait behaviour for rows already locked by another transaction. Requires a dialect whose lock renderer reports SupportsSourceLocks.
public JoinOptions ForUpdate(LockWaitMode wait)
Parameters
waitLockWaitModeHow to react to a row already locked by another transaction.
Returns
- JoinOptions
This instance, to allow chaining.
ManyToMany<TParent, TChild, TJunction, TParentKey, TChildKey>(Expression<Func<TParent, TParentKey>>, Expression<Func<TJunction, TParentKey>>, Expression<Func<TChild, TChildKey>>, Expression<Func<TJunction, TChildKey>>)
Configures a many-to-many relationship for a collection JoinInto call locally, without
declaring it in metadata: the keys on both principal sides and the two junction foreign keys that
reference them. The configuration fully replaces the declared relationship for this call.
public JoinOptions ManyToMany<TParent, TChild, TJunction, TParentKey, TChildKey>(Expression<Func<TParent, TParentKey>> parentKey, Expression<Func<TJunction, TParentKey>> junctionParentForeignKey, Expression<Func<TChild, TChildKey>> childKey, Expression<Func<TJunction, TChildKey>> junctionChildForeignKey) where TChild : class where TJunction : class
Parameters
parentKeyExpression<Func<TParent, TParentKey>>Selects the parent-side key property, for example
p => p.Id.junctionParentForeignKeyExpression<Func<TJunction, TParentKey>>Selects the junction foreign key referencing the parent key, for example
l => l.ParentId.childKeyExpression<Func<TChild, TChildKey>>Selects the child-side key property, for example
c => c.Id.junctionChildForeignKeyExpression<Func<TJunction, TChildKey>>Selects the junction foreign key referencing the child key, for example
l => l.ChildId.
Returns
- JoinOptions
This instance, to allow chaining.
Type Parameters
TParentThe parent entity type of the calling
JoinInto.TChildThe child entity type of the calling
JoinInto.TJunctionThe junction (link) entity type.
TParentKeyThe property type shared by the parent key and the junction parent foreign key.
TChildKeyThe property type shared by the child key and the junction child foreign key.
Exceptions
- ArgumentNullException
A selector is null.
- InvalidOperationException
A relationship was already configured on this instance.
- NotSupportedException
A key does not match its junction foreign key's type.
OneToOne<TParent, TChild, TKey>(Expression<Func<TParent, TKey>>, Expression<Func<TChild, TKey>>)
Configures the relationship for a one-to-one JoinInto call locally, without declaring it in
metadata: the parent-side key on TParent and the (trusted, not validated)
unique foreign key on TChild. The foreign-key uniqueness is not checked by
the core against the schema or the data; the only runtime guard rejects two distinct non-null
child identities for one parent. The configuration fully replaces the declared relationship for this
call.
public JoinOptions OneToOne<TParent, TChild, TKey>(Expression<Func<TParent, TKey>> parentKey, Expression<Func<TChild, TKey>> childForeignKey) where TChild : class
Parameters
parentKeyExpression<Func<TParent, TKey>>Selects the parent-side key property, for example
p => p.Id.childForeignKeyExpression<Func<TChild, TKey>>Selects the foreign-key property on the child, for example
c => c.ParentId.
Returns
- JoinOptions
This instance, to allow chaining.
Type Parameters
TParentThe parent entity type of the calling
JoinInto.TChildThe child entity type of the calling
JoinInto.TKeyThe property type shared by the parent key and the child foreign key.
Exceptions
- ArgumentNullException
A selector is null.
- InvalidOperationException
A relationship was already configured on this instance.
SuppressCartesianWarning()
Suppresses the JoinInto.MultipleCollections warning that is emitted when a query declares
two or more collection navigations (including many-to-many declarations), whose joins multiply
the parent rows. Suppression applies only to this join, but the warning is silenced for the whole
query as soon as any declared join sets it. The flag is never part of the plan key and never
throws; it only affects the diagnostic.
public JoinOptions SuppressCartesianWarning()
Returns
- JoinOptions
This instance, to allow chaining.
WithJoinHint(string)
Attaches a provider-specific hint to this join, for example SQL Server
j => j.WithJoinHint("loop") which renders inner loop join. On
PostgreSQL/MySQL/MariaDB the hint is folded into the statement-level /*+ ... */ comment
(append the aliases yourself, e.g. NestLoop(t1 t2)); a dialect that supports neither form
rejects the command with NotSupportedException.
public JoinOptions WithJoinHint(string hint)
Parameters
hintstringThe join hint text; must be non-empty.
Returns
- JoinOptions
This instance, to allow chaining.
Exceptions
- ArgumentException
hintis null, empty or whitespace.
WithJoinTableHint(params string[])
Attaches table-level hints to this join, for example SQL Server
j => j.WithJoinTableHint("nolock") which renders a WITH (nolock) clause on that
joined table only. This is the per-join counterpart of WithTableHint(params string[]) and
is distinct from the optimizer join hint WithJoinHint(string); unlike
WithTablesInScopeHint(params string[]) it never leaks to the other physical
tables. Hints are rendered verbatim, so only pass trusted values; null/blank entries are ignored,
and a call that supplies only ignored entries leaves the hints unchanged. Requires a dialect that
supports table hints (see SupportsTableHints) and a physical-table join
source (an APPLY, derived-table, table-valued-function or XML/pivot join source is rejected).
public JoinOptions WithJoinTableHint(params string[] hints)
Parameters
hintsstring[]The table hints to apply to the joined table (for example
nolock).
Returns
- JoinOptions
This instance, to allow chaining.