Class FromOptions
Per-query options for the primary FROM source, configured at query start through
From<T>(IDataContext, Action<FromOptions>, Action<EntityMetadataBuilder<T>>?)
(or the raw-table From(string, Action<FromOptions>) overload). The values are copied into
the returned builder, so the options object is not retained.
public sealed class FromOptions
- Inheritance
-
FromOptions
- Inherited Members
- Extension Methods
Methods
ForShare()
Locks the selected rows of this 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 source only. Requires a dialect whose lock renderer reports
SupportsSourceLocks.
public FromOptions ForShare()
Returns
- FromOptions
This instance, to allow chaining.
ForShare(LockWaitMode)
Locks the selected rows of this 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 FromOptions ForShare(LockWaitMode wait)
Parameters
waitLockWaitModeHow to react to a row already locked by another transaction.
Returns
- FromOptions
This instance, to allow chaining.
ForUpdate()
Locks the selected rows of this 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 source only. Requires a dialect whose lock renderer reports
SupportsSourceLocks; a dialect without it (for example MariaDB)
rejects the command with NotSupportedException. A whole-query
ForUpdate() cannot be combined with a source lock.
public FromOptions ForUpdate()
Returns
- FromOptions
This instance, to allow chaining.
ForUpdate(LockWaitMode)
Locks the selected rows of this 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 FromOptions ForUpdate(LockWaitMode wait)
Parameters
waitLockWaitModeHow to react to a row already locked by another transaction.
Returns
- FromOptions
This instance, to allow chaining.
TableSample(double, TableSampleMethod, double?)
Reads only percent percent of the primary table with a TABLESAMPLE
modifier; seed makes the sample repeatable. Requires a dialect that supports it
(see TableSample).
public FromOptions TableSample(double percent, TableSampleMethod method = TableSampleMethod.System, double? seed = null)
Parameters
percentdoubleThe percentage of the table to sample; must be in
(0, 100].methodTableSampleMethodThe sampling algorithm.
seeddouble?An optional seed that makes the sample repeatable.
Returns
- FromOptions
This instance, to allow chaining.
Exceptions
- ArgumentOutOfRangeException
percentis not finite or is outside(0, 100].
WithIndex(IndexHintKind, params string[])
Attaches an index hint with an explicit kind to the primary physical table.
With Ignore and no names, SQLite renders NOT INDEXED. Requires
a dialect that supports index hints (see IndexHints). Null/blank names
are ignored: a call with no usable name is a no-op unless kind is
Ignore.
public FromOptions WithIndex(IndexHintKind kind, params string[] indexes)
Parameters
kindIndexHintKindWhether to use, force or ignore the indexes.
indexesstring[]The index names to hint; may be empty for Ignore.
Returns
- FromOptions
This instance, to allow chaining.
WithIndex(params string[])
Attaches an index hint to the primary physical table, asking the planner to consider
indexes (USE INDEX on MySQL/MariaDB, INDEXED BY on SQLite,
WITH (INDEX(...)) on SQL Server). Requires a dialect that supports index hints (see
IndexHints); a dialect without a native form rejects the command with
NotSupportedException. The names are emitted verbatim, so only use trusted values.
Use the overload taking an NextORM.Core.FromOptions.IndexHintKind to force or ignore the indexes.
public FromOptions WithIndex(params string[] indexes)
Parameters
indexesstring[]The index names to hint; never empty.
Returns
- FromOptions
This instance, to allow chaining.
WithSubQueryHint(string)
Attaches a provider-specific hint to a derived-table source (for example a PostgreSQL
pg_hint_plan or MySQL optimizer hint), for example
ctx.From(subquery, o => o.WithSubQueryHint("NestLoop(t1)")). Only a
From(...) overload whose source is an explicit subquery can carry it; the SQL Server
dialect rejects it because a query hint cannot be appended to a subselect.
public FromOptions WithSubQueryHint(string hint)
Parameters
hintstringThe subquery hint text; must be non-empty.
Returns
- FromOptions
This instance, to allow chaining.
Exceptions
- ArgumentException
hintis null, empty or whitespace.
WithTableHint(params string[])
Attaches table-level hints to the primary physical table, for example
ctx.From<IComplexEntity>(o => o.WithTableHint("nolock")) which renders
from complex_entity with (nolock). Requires a dialect that supports table hints (see
SupportsTableHints); the hints are rendered verbatim, so only use
trusted values. Null/blank entries are ignored: a call that supplies no usable hint leaves the
options unchanged.
public FromOptions WithTableHint(params string[] hints)
Parameters
hintsstring[]The table hints to apply to the primary source (for example
nolock).
Returns
- FromOptions
This instance, to allow chaining.
WithoutIndex()
Tells the SQLite planner not to use any index (NOT INDEXED), or asks other dialects to
ignore every named index. Requires a dialect that supports index hints (see
IndexHints).
public FromOptions WithoutIndex()
Returns
- FromOptions
This instance, to allow chaining.