Class DataContextExtensions
Provider-independent helpers and convenience overloads for IDataContext. These used to be default interface methods; keeping them outside the interface leaves the provider-implemented contract (the role interfaces) free of engine-independent behavior.
public static class DataContextExtensions
- Inheritance
-
DataContextExtensions
- Inherited Members
Methods
Any(IDataContext, IPreparedQueryCommand<bool>, params ReadOnlySpan<object?>)
Synchronously determines whether the query produces at least one row.
public static bool Any(this IDataContext dataContext, IPreparedQueryCommand<bool> preparedQueryCommand, params ReadOnlySpan<object?> @params)
Parameters
dataContextIDataContextThe context to execute against.
preparedQueryCommandIPreparedQueryCommand<bool>The prepared query to evaluate.
paramsReadOnlySpan<object>Positional parameter values, in the order the SQL references them.
Returns
AnyAsync(IDataContext, IPreparedQueryCommand<bool>, params object[]?)
Asynchronously determines whether the query produces at least one row.
public static Task<bool> AnyAsync(this IDataContext dataContext, IPreparedQueryCommand<bool> preparedQueryCommand, params object[]? @params)
Parameters
dataContextIDataContextThe context to execute against.
preparedQueryCommandIPreparedQueryCommand<bool>The prepared query to evaluate.
paramsobject[]Positional parameter values, in the order the SQL references them.
Returns
AnyAsync(IDataContext, IPreparedQueryCommand<bool>, object[]?, CancellationToken)
Asynchronously determines whether the query produces at least one row. Stops after the first matching row rather than materializing the full result.
public static Task<bool> AnyAsync(this IDataContext dataContext, IPreparedQueryCommand<bool> preparedQueryCommand, object[]? @params, CancellationToken cancellationToken)
Parameters
dataContextIDataContextThe context to execute against.
preparedQueryCommandIPreparedQueryCommand<bool>The prepared query to evaluate.
paramsobject[]Positional parameter values, in the order the SQL references them.
cancellationTokenCancellationTokenToken used to cancel the operation.
Returns
AnyAsync(IDataContext, IPreparedQueryCommand<bool>, CancellationToken)
Asynchronously determines whether the query produces at least one row, using no parameters.
public static Task<bool> AnyAsync(this IDataContext dataContext, IPreparedQueryCommand<bool> preparedQueryCommand, CancellationToken cancellationToken)
Parameters
dataContextIDataContextThe context to execute against.
preparedQueryCommandIPreparedQueryCommand<bool>The prepared query to evaluate.
cancellationTokenCancellationTokenToken used to cancel the operation.
Returns
CreateBulkInsertBuilder<TEntity>(IDataContext, BulkInsertOptions, Action<EntityMetadataBuilder<TEntity>>?)
Starts a bulk insert with explicit BulkInsertOptions. The type's metadata is resolved
lazily and cached per process, exactly like CreateInsertBuilder<TEntity>(IDataContext, Action<EntityMetadataBuilder<TEntity>>?); the write uses the
provider's native bulk API where one exists and a chunked parameterised INSERT ... VALUES
otherwise. The options shape the statement (batch limits, identity, conflict handling, timeout and
progress).
public static BulkInsertBuilder<TEntity> CreateBulkInsertBuilder<TEntity>(this IDataContext dataContext, BulkInsertOptions options, Action<EntityMetadataBuilder<TEntity>>? configEntity = null)
Parameters
dataContextIDataContextThe context to execute against.
optionsBulkInsertOptionsThe write options.
configEntityAction<EntityMetadataBuilder<TEntity>>Optional mapping configuration, run only when the type is first mapped.
Returns
- BulkInsertBuilder<TEntity>
A builder for the bulk insert.
Type Parameters
TEntityThe mapped entity type to write.
Exceptions
- ArgumentNullException
optionsis null.- ArgumentOutOfRangeException
An option value is not positive.
CreateBulkInsertBuilder<TEntity>(IDataContext, Action<EntityMetadataBuilder<TEntity>>?)
Starts a bulk insert over the mapping of TEntity and returns its fluent
builder. The type's metadata is resolved lazily and cached per process, exactly like
CreateInsertBuilder<TEntity>(IDataContext, Action<EntityMetadataBuilder<TEntity>>?); configEntity therefore runs only on the first
call for TEntity. The write uses the provider's native bulk API where one
exists and a chunked parameterised INSERT ... VALUES otherwise.
public static BulkInsertBuilder<TEntity> CreateBulkInsertBuilder<TEntity>(this IDataContext dataContext, Action<EntityMetadataBuilder<TEntity>>? configEntity = null)
Parameters
dataContextIDataContextThe context to execute against.
configEntityAction<EntityMetadataBuilder<TEntity>>Optional mapping configuration, run only when the type is first mapped.
Returns
- BulkInsertBuilder<TEntity>
A builder for the bulk insert.
Type Parameters
TEntityThe mapped entity type to write.
CreateBulkInsertBuilder<TEntity>(IDataContext, Func<BulkInsertOptionsBuilder, BulkInsertOptionsBuilder>, Action<EntityMetadataBuilder<TEntity>>?)
Starts a bulk insert configured with the fluent BulkInsertOptionsBuilder. The type's
metadata is resolved lazily and cached per process, exactly like CreateInsertBuilder<TEntity>(IDataContext, Action<EntityMetadataBuilder<TEntity>>?).
The callback must be an expression lambda that returns the builder (for example
o => o.MaxBatchSize(1_000)), which keeps it distinct from the
EntityMetadataBuilder<T> overload.
public static BulkInsertBuilder<TEntity> CreateBulkInsertBuilder<TEntity>(this IDataContext dataContext, Func<BulkInsertOptionsBuilder, BulkInsertOptionsBuilder> configure, Action<EntityMetadataBuilder<TEntity>>? configEntity = null)
Parameters
dataContextIDataContextThe context to execute against.
configureFunc<BulkInsertOptionsBuilder, BulkInsertOptionsBuilder>Configures the write options; the returned builder is ignored.
configEntityAction<EntityMetadataBuilder<TEntity>>Optional mapping configuration, run only when the type is first mapped.
Returns
- BulkInsertBuilder<TEntity>
A builder for the bulk insert.
Type Parameters
TEntityThe mapped entity type to write.
Exceptions
- ArgumentNullException
configureis null.
CreateCommand<T>(IDataContext, QueryDefinition)
Creates a typed query command from a QueryDefinition. This is the single factory the builders use; it replaces the previous overloads that took the whole query shape as a long parameter list.
public static QueryCommand<T> CreateCommand<T>(this IDataContext dataContext, QueryDefinition definition)
Parameters
dataContextIDataContextdefinitionQueryDefinition
Returns
- QueryCommand<T>
Type Parameters
T
CreateDeleteBuilder<TEntity>(IDataContext, Action<EntityMetadataBuilder<TEntity>>?)
Starts a DELETE over the mapping of TEntity and returns its fluent
builder. The type's metadata is resolved lazily and cached per process, exactly like
From<T>(); configEntity therefore runs only on the first call for
TEntity.
public static DeleteBuilder<TEntity> CreateDeleteBuilder<TEntity>(this IDataContext dataContext, Action<EntityMetadataBuilder<TEntity>>? configEntity = null)
Parameters
dataContextIDataContextThe context to execute against.
configEntityAction<EntityMetadataBuilder<TEntity>>Optional mapping configuration, run only when the type is first mapped.
Returns
- DeleteBuilder<TEntity>
A builder for the delete.
Type Parameters
TEntityThe mapped entity type whose rows are deleted.
CreateDeleteJoinBuilder<T1, T2>(JoinedEntityBuilder<T1, T2>)
Starts the row-returning multi-table DELETE over the join of query: the
target is the first table of the chain and the returned values may read the joined tables. Only
INNER Join joins are supported; outer/cross joins are rejected. PostgreSQL renders
DELETE ... USING ... RETURNING; every other provider rejects the returning form. The
whole-projection (identity) form returns every returnable mapped property of every item slot, in
slot order. Consumed through Returning() or
Returning<TResult>(Expression<Func<TProjection, TResult>>).
public static DeleteJoinBuilder<Projection<T1, T2>> CreateDeleteJoinBuilder<T1, T2>(this JoinedEntityBuilder<T1, T2> query)
Parameters
queryJoinedEntityBuilder<T1, T2>The joined query selecting the rows to delete.
Returns
- DeleteJoinBuilder<Projection<T1, T2>>
A builder for the returned-row selector.
Type Parameters
T1The target entity type whose rows are deleted (the first table).
T2The joined entity type.
CreateDeleteJoinBuilder<T1, T2, T3>(JoinedEntityBuilder<T1, T2, T3>)
Starts the row-returning multi-table DELETE over a three-table join. See CreateDeleteJoinBuilder<T1, T2>(JoinedEntityBuilder<T1, T2>) for the full contract.
public static DeleteJoinBuilder<Projection<T1, T2, T3>> CreateDeleteJoinBuilder<T1, T2, T3>(this JoinedEntityBuilder<T1, T2, T3> query)
Parameters
queryJoinedEntityBuilder<T1, T2, T3>The joined query selecting the rows to delete.
Returns
- DeleteJoinBuilder<Projection<T1, T2, T3>>
A builder for the returned-row selector.
Type Parameters
T1The target entity type whose rows are deleted.
T2The second joined entity type.
T3The third joined entity type.
CreateDeleteJoinBuilder<T1, T2, T3, T4>(JoinedEntityBuilder<T1, T2, T3, T4>)
Starts the row-returning multi-table DELETE over a four-table join. See CreateDeleteJoinBuilder<T1, T2>(JoinedEntityBuilder<T1, T2>) for the full contract.
public static DeleteJoinBuilder<Projection<T1, T2, T3, T4>> CreateDeleteJoinBuilder<T1, T2, T3, T4>(this JoinedEntityBuilder<T1, T2, T3, T4> query)
Parameters
queryJoinedEntityBuilder<T1, T2, T3, T4>The joined query selecting the rows to delete.
Returns
- DeleteJoinBuilder<Projection<T1, T2, T3, T4>>
A builder for the returned-row selector.
Type Parameters
T1The target entity type whose rows are deleted.
T2The second joined entity type.
T3The third joined entity type.
T4The fourth joined entity type.
CreateDeleteJoinBuilder<T1, T2, T3, T4, T5>(JoinedEntityBuilder<T1, T2, T3, T4, T5>)
Starts the row-returning multi-table DELETE over a five-table join. See CreateDeleteJoinBuilder<T1, T2>(JoinedEntityBuilder<T1, T2>) for the full contract.
public static DeleteJoinBuilder<Projection<T1, T2, T3, T4, T5>> CreateDeleteJoinBuilder<T1, T2, T3, T4, T5>(this JoinedEntityBuilder<T1, T2, T3, T4, T5> query)
Parameters
queryJoinedEntityBuilder<T1, T2, T3, T4, T5>The joined query selecting the rows to delete.
Returns
- DeleteJoinBuilder<Projection<T1, T2, T3, T4, T5>>
A builder for the returned-row selector.
Type Parameters
T1The target entity type whose rows are deleted.
T2The second joined entity type.
T3The third joined entity type.
T4The fourth joined entity type.
T5The fifth joined entity type.
CreateDeleteJoinBuilder<T1, T2, T3, T4, T5, T6>(JoinedEntityBuilder<T1, T2, T3, T4, T5, T6>)
Starts the row-returning multi-table DELETE over a six-table join. See CreateDeleteJoinBuilder<T1, T2>(JoinedEntityBuilder<T1, T2>) for the full contract.
public static DeleteJoinBuilder<Projection<T1, T2, T3, T4, T5, T6>> CreateDeleteJoinBuilder<T1, T2, T3, T4, T5, T6>(this JoinedEntityBuilder<T1, T2, T3, T4, T5, T6> query)
Parameters
queryJoinedEntityBuilder<T1, T2, T3, T4, T5, T6>The joined query selecting the rows to delete.
Returns
- DeleteJoinBuilder<Projection<T1, T2, T3, T4, T5, T6>>
A builder for the returned-row selector.
Type Parameters
T1The target entity type whose rows are deleted.
T2The second joined entity type.
T3The third joined entity type.
T4The fourth joined entity type.
T5The fifth joined entity type.
T6The sixth joined entity type.
CreateDeleteJoinBuilder<T1, T2, T3, T4, T5, T6, T7>(JoinedEntityBuilder<T1, T2, T3, T4, T5, T6, T7>)
Starts the row-returning multi-table DELETE over a seven-table join. See CreateDeleteJoinBuilder<T1, T2>(JoinedEntityBuilder<T1, T2>) for the full contract.
public static DeleteJoinBuilder<Projection<T1, T2, T3, T4, T5, T6, T7>> CreateDeleteJoinBuilder<T1, T2, T3, T4, T5, T6, T7>(this JoinedEntityBuilder<T1, T2, T3, T4, T5, T6, T7> query)
Parameters
queryJoinedEntityBuilder<T1, T2, T3, T4, T5, T6, T7>The joined query selecting the rows to delete.
Returns
- DeleteJoinBuilder<Projection<T1, T2, T3, T4, T5, T6, T7>>
A builder for the returned-row selector.
Type Parameters
T1The target entity type whose rows are deleted.
T2The second joined entity type.
T3The third joined entity type.
T4The fourth joined entity type.
T5The fifth joined entity type.
T6The sixth joined entity type.
T7The seventh joined entity type.
CreateDeleteJoinBuilder<T1, T2, T3, T4, T5, T6, T7, T8>(JoinedEntityBuilder<T1, T2, T3, T4, T5, T6, T7, T8>)
Starts the row-returning multi-table DELETE over an eight-table join. See CreateDeleteJoinBuilder<T1, T2>(JoinedEntityBuilder<T1, T2>) for the full contract.
public static DeleteJoinBuilder<Projection<T1, T2, T3, T4, T5, T6, T7, T8>> CreateDeleteJoinBuilder<T1, T2, T3, T4, T5, T6, T7, T8>(this JoinedEntityBuilder<T1, T2, T3, T4, T5, T6, T7, T8> query)
Parameters
queryJoinedEntityBuilder<T1, T2, T3, T4, T5, T6, T7, T8>The joined query selecting the rows to delete.
Returns
- DeleteJoinBuilder<Projection<T1, T2, T3, T4, T5, T6, T7, T8>>
A builder for the returned-row selector.
Type Parameters
T1The target entity type whose rows are deleted.
T2The second joined entity type.
T3The third joined entity type.
T4The fourth joined entity type.
T5The fifth joined entity type.
T6The sixth joined entity type.
T7The seventh joined entity type.
T8The eighth joined entity type.
CreateInsertBuilder<TEntity>(IDataContext, Action<EntityMetadataBuilder<TEntity>>?)
Starts an INSERT over the mapping of TEntity and returns its fluent
builder. The type's metadata is resolved lazily and cached per process, exactly like
From<T>(); configEntity therefore runs only on the first call for
TEntity (declare keys/identity/computed columns there or with attributes).
public static InsertBuilder<TEntity> CreateInsertBuilder<TEntity>(this IDataContext dataContext, Action<EntityMetadataBuilder<TEntity>>? configEntity = null)
Parameters
dataContextIDataContextThe context to execute against.
configEntityAction<EntityMetadataBuilder<TEntity>>Optional mapping configuration, run only when the type is first mapped.
Returns
- InsertBuilder<TEntity>
A builder for the insert.
Type Parameters
TEntityThe mapped entity type to insert.
CreateMergeBuilder<TEntity>(IDataContext, Action<EntityMetadataBuilder<TEntity>>?)
Starts a key upsert over the mapping of TEntity and returns its fluent
builder. The source row set is supplied with Using and the match key with OnKeys;
the statement is rendered as INSERT ... ON CONFLICT ... DO UPDATE,
INSERT ... ON DUPLICATE KEY UPDATE or MERGE depending on the provider. Like
CreateInsertBuilder<TEntity>(IDataContext, Action<EntityMetadataBuilder<TEntity>>?), the type's metadata is resolved lazily and cached per process,
so configEntity runs only on the first call for TEntity.
public static MergeBuilder<TEntity> CreateMergeBuilder<TEntity>(this IDataContext dataContext, Action<EntityMetadataBuilder<TEntity>>? configEntity = null)
Parameters
dataContextIDataContextThe context to execute against.
configEntityAction<EntityMetadataBuilder<TEntity>>Optional mapping configuration, run only when the type is first mapped.
Returns
- MergeBuilder<TEntity>
A builder for the key upsert.
Type Parameters
TEntityThe mapped entity type upserted.
CreateQueryBuilder(IDataContext, string)
Explicit factory alias of From(IDataContext, string): starts a query against a raw table (or CTE) name.
public static EntityBuilder<TableAlias> CreateQueryBuilder(this IDataContext dataContext, string table)
Parameters
dataContextIDataContextThe context to execute against.
tablestringThe table or CTE name.
Returns
- EntityBuilder<TableAlias>
A builder for composing the query.
CreateQueryBuilder(IDataContext, string, Action<FromOptions>)
Explicit factory alias of From(IDataContext, string, Action<FromOptions>): starts a query against a raw table (or CTE) name with per-query source options.
public static EntityBuilder<TableAlias> CreateQueryBuilder(this IDataContext dataContext, string table, Action<FromOptions> options)
Parameters
dataContextIDataContextThe context to execute against.
tablestringThe table or CTE name.
optionsAction<FromOptions>Configures the primary source.
Returns
- EntityBuilder<TableAlias>
A builder for composing the query.
CreateQueryBuilderFromSql(IDataContext, string, object?)
Explicit factory alias of FromSql(IDataContext, string, object?): starts a query from a raw
SQL fragment used as a composable FROM source.
public static EntityBuilder<TableAlias> CreateQueryBuilderFromSql(this IDataContext dataContext, string sql, object? parameters = null)
Parameters
dataContextIDataContextThe context to execute against.
sqlstringThe raw SQL fragment.
parametersobjectAn object whose public properties become the named parameters.
Returns
- EntityBuilder<TableAlias>
A builder for composing the query.
CreateQueryBuilder<TResult>(IDataContext, EntityBuilder<TResult>)
Explicit factory alias of From<TResult>(IDataContext, EntityBuilder<TResult>): starts a new builder sharing an existing builder's source and definition.
public static EntityBuilder<TResult> CreateQueryBuilder<TResult>(this IDataContext dataContext, EntityBuilder<TResult> builder)
Parameters
dataContextIDataContextThe context to execute against.
builderEntityBuilder<TResult>The builder to copy the query shape from.
Returns
- EntityBuilder<TResult>
A new builder bound to
dataContext.
Type Parameters
TResultThe projected element type.
CreateQueryBuilder<TResult>(IDataContext, EntityBuilder<TResult>, Action<FromOptions>)
Explicit factory alias of From<TResult>(IDataContext, EntityBuilder<TResult>, Action<FromOptions>): starts a new builder sharing an existing builder's source and definition, with per-source options.
public static EntityBuilder<TResult> CreateQueryBuilder<TResult>(this IDataContext dataContext, EntityBuilder<TResult> builder, Action<FromOptions> options)
Parameters
dataContextIDataContextThe context to execute against.
builderEntityBuilder<TResult>The builder to copy the query shape from.
optionsAction<FromOptions>Configures the derived-table source.
Returns
- EntityBuilder<TResult>
A new builder bound to
dataContext.
Type Parameters
TResultThe projected element type.
CreateQueryBuilder<TResult>(IDataContext, QueryCommand<TResult>)
Explicit factory alias of From<TResult>(IDataContext, QueryCommand<TResult>): starts a query from an existing command's definition.
public static EntityBuilder<TResult> CreateQueryBuilder<TResult>(this IDataContext dataContext, QueryCommand<TResult> query)
Parameters
dataContextIDataContextThe context to execute against.
queryQueryCommand<TResult>The command whose definition drives the query.
Returns
- EntityBuilder<TResult>
A builder for composing the query further.
Type Parameters
TResultThe projected element type.
CreateQueryBuilder<TResult>(IDataContext, QueryCommand<TResult>, Action<FromOptions>)
Explicit factory alias of From<TResult>(IDataContext, QueryCommand<TResult>, Action<FromOptions>): starts a query from an existing command's definition with per-source options.
public static EntityBuilder<TResult> CreateQueryBuilder<TResult>(this IDataContext dataContext, QueryCommand<TResult> query, Action<FromOptions> options)
Parameters
dataContextIDataContextThe context to execute against.
queryQueryCommand<TResult>The command whose definition drives the query.
optionsAction<FromOptions>Configures the derived-table source.
Returns
- EntityBuilder<TResult>
A builder for composing the query further.
Type Parameters
TResultThe projected element type.
CreateQueryBuilder<TResult>(IDataContext, TempTableSource<TResult>)
Explicit factory alias of From<TResult>(IDataContext, TempTableSource<TResult>): starts a query over a lazy temporary table.
public static EntityBuilder<TableAlias> CreateQueryBuilder<TResult>(this IDataContext dataContext, TempTableSource<TResult> tempTable)
Parameters
dataContextIDataContextThe context to execute against.
tempTableTempTableSource<TResult>The lazy source to materialise and read.
Returns
- EntityBuilder<TableAlias>
A builder for composing the query over the temporary table.
Type Parameters
TResultThe source query's projected row type.
CreateQueryBuilder<T>(IDataContext, Action<EntityMetadataBuilder<T>>?)
Explicit factory alias of From<T>(IDataContext, Action<EntityMetadataBuilder<T>>?): starts a
query over the mapping of T.
public static EntityBuilder<T> CreateQueryBuilder<T>(this IDataContext dataContext, Action<EntityMetadataBuilder<T>>? configEntity = null)
Parameters
dataContextIDataContextThe context to execute against.
configEntityAction<EntityMetadataBuilder<T>>Optional mapping configuration, run only when the type is first mapped.
Returns
- EntityBuilder<T>
A builder for composing the query.
Type Parameters
TThe mapped entity type.
CreateQueryBuilder<T>(IDataContext, Action<FromOptions>, Action<EntityMetadataBuilder<T>>?)
Explicit factory alias of From<T>(IDataContext, Action<FromOptions>, Action<EntityMetadataBuilder<T>>?):
starts a query over the mapping of T with per-query source options.
public static EntityBuilder<T> CreateQueryBuilder<T>(this IDataContext dataContext, Action<FromOptions> options, Action<EntityMetadataBuilder<T>>? configEntity = null)
Parameters
dataContextIDataContextThe context to execute against.
optionsAction<FromOptions>Configures the primary source.
configEntityAction<EntityMetadataBuilder<T>>Optional mapping configuration, run only when the type is first mapped.
Returns
- EntityBuilder<T>
A builder for composing the query.
Type Parameters
TThe mapped entity type.
CreateSqliteFts5CommandBuilder(IDataContext, string)
Starts a SQLite FTS5 maintenance/control command over a raw FTS5 table name. The returned builder
selects one operation (automerge, crisismerge, merge, optimize,
rebuild or integrity-check) and then renders or executes it through the FTS5 control
interface; providers without FTS5 reject it with NotSupportedException. The table name
is preserved verbatim (no trimming or splitting; a dot is a literal character).
public static SqliteFts5CommandBuilder CreateSqliteFts5CommandBuilder(this IDataContext dataContext, string tableName)
Parameters
dataContextIDataContextThe context to execute against.
tableNamestringThe raw FTS5 table name; must be non-null and not empty/whitespace, and must not contain a NUL character.
Returns
- SqliteFts5CommandBuilder
A builder for the FTS5 maintenance command.
Exceptions
- ArgumentNullException
dataContextortableNameis null.- ArgumentException
tableNameis empty, all whitespace, or contains a NUL character.
CreateTruncateBuilder<TEntity>(IDataContext, Action<EntityMetadataBuilder<TEntity>>?)
Starts a TRUNCATE TABLE over the mapping of TEntity and returns its
terminal. Resets the table faster than CreateDeleteBuilder<T>().All(); providers without a
native TRUNCATE (SQLite) reject it.
public static TruncateBuilder<TEntity> CreateTruncateBuilder<TEntity>(this IDataContext dataContext, Action<EntityMetadataBuilder<TEntity>>? configEntity = null)
Parameters
dataContextIDataContextThe context to execute against.
configEntityAction<EntityMetadataBuilder<TEntity>>Optional mapping configuration, run only when the type is first mapped.
Returns
- TruncateBuilder<TEntity>
A builder for the truncate.
Type Parameters
TEntityThe mapped entity type whose table is truncated.
CreateUpdateBuilder<TEntity>(IDataContext, Action<EntityMetadataBuilder<TEntity>>?)
Starts an UPDATE over the mapping of TEntity and returns its fluent
builder. Add the written columns with Set and the row filter with Where; omitting
Where updates every row. Like CreateInsertBuilder<TEntity>(IDataContext, Action<EntityMetadataBuilder<TEntity>>?), the type's metadata is
resolved lazily and cached per process, so configEntity runs only on the first
call for TEntity.
public static UpdateBuilder<TEntity> CreateUpdateBuilder<TEntity>(this IDataContext dataContext, Action<EntityMetadataBuilder<TEntity>>? configEntity = null)
Parameters
dataContextIDataContextThe context to execute against.
configEntityAction<EntityMetadataBuilder<TEntity>>Optional mapping configuration, run only when the type is first mapped.
Returns
- UpdateBuilder<TEntity>
A builder for the update.
Type Parameters
TEntityThe mapped entity type to update.
CreateUpdateJoinBuilder<T1, T2>(JoinedEntityBuilder<T1, T2>)
Starts a multi-table UPDATE over the join of query: the target is the
first table of the chain and the SET values may read the joined tables. Only INNER
Join joins are supported; outer/cross joins are rejected because folding the join conditions
into the filter would change which rows are updated. PostgreSQL and SQLite render
UPDATE ... FROM; SQL Server renders UPDATE <alias> ... FROM ... JOIN;
MySQL/MariaDB render UPDATE ... JOIN ... SET. ClickHouse and the in-memory provider reject it.
public static UpdateJoinBuilder<Projection<T1, T2>> CreateUpdateJoinBuilder<T1, T2>(this JoinedEntityBuilder<T1, T2> query)
Parameters
queryJoinedEntityBuilder<T1, T2>The joined query selecting the rows to update.
Returns
- UpdateJoinBuilder<Projection<T1, T2>>
A builder for the assignments and the filter.
Type Parameters
T1The target entity type whose rows are updated (the first table).
T2The joined entity type.
CreateUpdateJoinBuilder<T1, T2, T3>(JoinedEntityBuilder<T1, T2, T3>)
Starts a multi-table UPDATE over a three-table join. See CreateUpdateJoinBuilder<T1, T2>(JoinedEntityBuilder<T1, T2>) for the full contract.
public static UpdateJoinBuilder<Projection<T1, T2, T3>> CreateUpdateJoinBuilder<T1, T2, T3>(this JoinedEntityBuilder<T1, T2, T3> query)
Parameters
queryJoinedEntityBuilder<T1, T2, T3>The joined query selecting the rows to update.
Returns
- UpdateJoinBuilder<Projection<T1, T2, T3>>
A builder for the assignments and the filter.
Type Parameters
T1The target entity type whose rows are updated.
T2The second joined entity type.
T3The third joined entity type.
CreateUpdateJoinBuilder<T1, T2, T3, T4>(JoinedEntityBuilder<T1, T2, T3, T4>)
Starts a multi-table UPDATE over a four-table join. See CreateUpdateJoinBuilder<T1, T2>(JoinedEntityBuilder<T1, T2>) for the full contract.
public static UpdateJoinBuilder<Projection<T1, T2, T3, T4>> CreateUpdateJoinBuilder<T1, T2, T3, T4>(this JoinedEntityBuilder<T1, T2, T3, T4> query)
Parameters
queryJoinedEntityBuilder<T1, T2, T3, T4>The joined query selecting the rows to update.
Returns
- UpdateJoinBuilder<Projection<T1, T2, T3, T4>>
A builder for the assignments and the filter.
Type Parameters
T1The target entity type whose rows are updated.
T2The second joined entity type.
T3The third joined entity type.
T4The fourth joined entity type.
CreateUpdateJoinBuilder<T1, T2, T3, T4, T5>(JoinedEntityBuilder<T1, T2, T3, T4, T5>)
Starts a multi-table UPDATE over a five-table join. See CreateUpdateJoinBuilder<T1, T2>(JoinedEntityBuilder<T1, T2>) for the full contract.
public static UpdateJoinBuilder<Projection<T1, T2, T3, T4, T5>> CreateUpdateJoinBuilder<T1, T2, T3, T4, T5>(this JoinedEntityBuilder<T1, T2, T3, T4, T5> query)
Parameters
queryJoinedEntityBuilder<T1, T2, T3, T4, T5>The joined query selecting the rows to update.
Returns
- UpdateJoinBuilder<Projection<T1, T2, T3, T4, T5>>
A builder for the assignments and the filter.
Type Parameters
T1The target entity type whose rows are updated.
T2The second joined entity type.
T3The third joined entity type.
T4The fourth joined entity type.
T5The fifth joined entity type.
CreateUpdateJoinBuilder<T1, T2, T3, T4, T5, T6>(JoinedEntityBuilder<T1, T2, T3, T4, T5, T6>)
Starts a multi-table UPDATE over a six-table join. See CreateUpdateJoinBuilder<T1, T2>(JoinedEntityBuilder<T1, T2>) for the full contract.
public static UpdateJoinBuilder<Projection<T1, T2, T3, T4, T5, T6>> CreateUpdateJoinBuilder<T1, T2, T3, T4, T5, T6>(this JoinedEntityBuilder<T1, T2, T3, T4, T5, T6> query)
Parameters
queryJoinedEntityBuilder<T1, T2, T3, T4, T5, T6>The joined query selecting the rows to update.
Returns
- UpdateJoinBuilder<Projection<T1, T2, T3, T4, T5, T6>>
A builder for the assignments and the filter.
Type Parameters
T1The target entity type whose rows are updated.
T2The second joined entity type.
T3The third joined entity type.
T4The fourth joined entity type.
T5The fifth joined entity type.
T6The sixth joined entity type.
CreateUpdateJoinBuilder<T1, T2, T3, T4, T5, T6, T7>(JoinedEntityBuilder<T1, T2, T3, T4, T5, T6, T7>)
Starts a multi-table UPDATE over a seven-table join. See CreateUpdateJoinBuilder<T1, T2>(JoinedEntityBuilder<T1, T2>) for the full contract.
public static UpdateJoinBuilder<Projection<T1, T2, T3, T4, T5, T6, T7>> CreateUpdateJoinBuilder<T1, T2, T3, T4, T5, T6, T7>(this JoinedEntityBuilder<T1, T2, T3, T4, T5, T6, T7> query)
Parameters
queryJoinedEntityBuilder<T1, T2, T3, T4, T5, T6, T7>The joined query selecting the rows to update.
Returns
- UpdateJoinBuilder<Projection<T1, T2, T3, T4, T5, T6, T7>>
A builder for the assignments and the filter.
Type Parameters
T1The target entity type whose rows are updated.
T2The second joined entity type.
T3The third joined entity type.
T4The fourth joined entity type.
T5The fifth joined entity type.
T6The sixth joined entity type.
T7The seventh joined entity type.
CreateUpdateJoinBuilder<T1, T2, T3, T4, T5, T6, T7, T8>(JoinedEntityBuilder<T1, T2, T3, T4, T5, T6, T7, T8>)
Starts a multi-table UPDATE over an eight-table join. See CreateUpdateJoinBuilder<T1, T2>(JoinedEntityBuilder<T1, T2>) for the full contract.
public static UpdateJoinBuilder<Projection<T1, T2, T3, T4, T5, T6, T7, T8>> CreateUpdateJoinBuilder<T1, T2, T3, T4, T5, T6, T7, T8>(this JoinedEntityBuilder<T1, T2, T3, T4, T5, T6, T7, T8> query)
Parameters
queryJoinedEntityBuilder<T1, T2, T3, T4, T5, T6, T7, T8>The joined query selecting the rows to update.
Returns
- UpdateJoinBuilder<Projection<T1, T2, T3, T4, T5, T6, T7, T8>>
A builder for the assignments and the filter.
Type Parameters
T1The target entity type whose rows are updated.
T2The second joined entity type.
T3The third joined entity type.
T4The fourth joined entity type.
T5The fifth joined entity type.
T6The sixth joined entity type.
T7The seventh joined entity type.
T8The eighth joined entity type.
DeleteAsync<TEntity>(IDataContext, TEntity, CancellationToken)
Asynchronously deletes the row identified by the declared key of entity in one
command, using the mapping's [Key]/.Key().
public static Task<int> DeleteAsync<TEntity>(this IDataContext dataContext, TEntity entity, CancellationToken cancellationToken = default)
Parameters
dataContextIDataContextThe context to execute against.
entityTEntityThe entity whose key identifies the row to delete.
cancellationTokenCancellationTokenCancels execution.
Returns
Type Parameters
TEntityThe mapped entity type.
Exceptions
- InvalidOperationException
The entity type declares no key.
DeleteAsync<T1, T2>(JoinedEntityBuilder<T1, T2>, CancellationToken)
Asynchronously deletes the rows of the first table matching the join. See Delete<T1, T2>(JoinedEntityBuilder<T1, T2>) for the full contract.
public static Task<int> DeleteAsync<T1, T2>(this JoinedEntityBuilder<T1, T2> query, CancellationToken cancellationToken = default)
Parameters
queryJoinedEntityBuilder<T1, T2>The joined query selecting the rows to delete.
cancellationTokenCancellationTokenCancels execution.
Returns
Type Parameters
T1The target entity type whose rows are deleted.
T2The joined entity type.
Exceptions
- NotSupportedException
The provider has no native multi-table
DELETE, or a join is not an INNERJoin.
DeleteAsync<T1, T2, T3>(JoinedEntityBuilder<T1, T2, T3>, CancellationToken)
Asynchronously deletes the rows of the first table of a three-table join that matches the join. See Delete<T1, T2>(JoinedEntityBuilder<T1, T2>) for the full contract.
public static Task<int> DeleteAsync<T1, T2, T3>(this JoinedEntityBuilder<T1, T2, T3> query, CancellationToken cancellationToken = default)
Parameters
queryJoinedEntityBuilder<T1, T2, T3>The joined query selecting the rows to delete.
cancellationTokenCancellationTokenCancels execution.
Returns
Type Parameters
T1The target entity type whose rows are deleted.
T2The second joined entity type.
T3The third joined entity type.
Exceptions
- NotSupportedException
The provider has no native multi-table
DELETE, or a join is not an INNERJoin.
DeleteAsync<T1, T2, T3, T4>(JoinedEntityBuilder<T1, T2, T3, T4>, CancellationToken)
Asynchronously deletes the rows of the first table of a four-table join that matches the join. See Delete<T1, T2>(JoinedEntityBuilder<T1, T2>) for the full contract.
public static Task<int> DeleteAsync<T1, T2, T3, T4>(this JoinedEntityBuilder<T1, T2, T3, T4> query, CancellationToken cancellationToken = default)
Parameters
queryJoinedEntityBuilder<T1, T2, T3, T4>The joined query selecting the rows to delete.
cancellationTokenCancellationTokenCancels execution.
Returns
Type Parameters
T1The target entity type whose rows are deleted.
T2The second joined entity type.
T3The third joined entity type.
T4The fourth joined entity type.
Exceptions
- NotSupportedException
The provider has no native multi-table
DELETE, or a join is not an INNERJoin.
DeleteAsync<T1, T2, T3, T4, T5>(JoinedEntityBuilder<T1, T2, T3, T4, T5>, CancellationToken)
Asynchronously deletes the rows of the first table of a five-table join that matches the join. See Delete<T1, T2>(JoinedEntityBuilder<T1, T2>) for the full contract.
public static Task<int> DeleteAsync<T1, T2, T3, T4, T5>(this JoinedEntityBuilder<T1, T2, T3, T4, T5> query, CancellationToken cancellationToken = default)
Parameters
queryJoinedEntityBuilder<T1, T2, T3, T4, T5>The joined query selecting the rows to delete.
cancellationTokenCancellationTokenCancels execution.
Returns
Type Parameters
T1The target entity type whose rows are deleted.
T2The second joined entity type.
T3The third joined entity type.
T4The fourth joined entity type.
T5The fifth joined entity type.
Exceptions
- NotSupportedException
The provider has no native multi-table
DELETE, or a join is not an INNERJoin.
DeleteAsync<T1, T2, T3, T4, T5, T6>(JoinedEntityBuilder<T1, T2, T3, T4, T5, T6>, CancellationToken)
Asynchronously deletes the rows of the first table of a six-table join that matches the join. See Delete<T1, T2>(JoinedEntityBuilder<T1, T2>) for the full contract.
public static Task<int> DeleteAsync<T1, T2, T3, T4, T5, T6>(this JoinedEntityBuilder<T1, T2, T3, T4, T5, T6> query, CancellationToken cancellationToken = default)
Parameters
queryJoinedEntityBuilder<T1, T2, T3, T4, T5, T6>The joined query selecting the rows to delete.
cancellationTokenCancellationTokenCancels execution.
Returns
Type Parameters
T1The target entity type whose rows are deleted.
T2The second joined entity type.
T3The third joined entity type.
T4The fourth joined entity type.
T5The fifth joined entity type.
T6The sixth joined entity type.
Exceptions
- NotSupportedException
The provider has no native multi-table
DELETE, or a join is not an INNERJoin.
DeleteAsync<T1, T2, T3, T4, T5, T6, T7>(JoinedEntityBuilder<T1, T2, T3, T4, T5, T6, T7>, CancellationToken)
Asynchronously deletes the rows of the first table of a seven-table join that matches the join. See Delete<T1, T2>(JoinedEntityBuilder<T1, T2>) for the full contract.
public static Task<int> DeleteAsync<T1, T2, T3, T4, T5, T6, T7>(this JoinedEntityBuilder<T1, T2, T3, T4, T5, T6, T7> query, CancellationToken cancellationToken = default)
Parameters
queryJoinedEntityBuilder<T1, T2, T3, T4, T5, T6, T7>The joined query selecting the rows to delete.
cancellationTokenCancellationTokenCancels execution.
Returns
Type Parameters
T1The target entity type whose rows are deleted.
T2The second joined entity type.
T3The third joined entity type.
T4The fourth joined entity type.
T5The fifth joined entity type.
T6The sixth joined entity type.
T7The seventh joined entity type.
Exceptions
- NotSupportedException
The provider has no native multi-table
DELETE, or a join is not an INNERJoin.
DeleteAsync<T1, T2, T3, T4, T5, T6, T7, T8>(JoinedEntityBuilder<T1, T2, T3, T4, T5, T6, T7, T8>, CancellationToken)
Asynchronously deletes the rows of the first table of an eight-table join that matches the join. See Delete<T1, T2>(JoinedEntityBuilder<T1, T2>) for the full contract.
public static Task<int> DeleteAsync<T1, T2, T3, T4, T5, T6, T7, T8>(this JoinedEntityBuilder<T1, T2, T3, T4, T5, T6, T7, T8> query, CancellationToken cancellationToken = default)
Parameters
queryJoinedEntityBuilder<T1, T2, T3, T4, T5, T6, T7, T8>The joined query selecting the rows to delete.
cancellationTokenCancellationTokenCancels execution.
Returns
Type Parameters
T1The target entity type whose rows are deleted.
T2The second joined entity type.
T3The third joined entity type.
T4The fourth joined entity type.
T5The fifth joined entity type.
T6The sixth joined entity type.
T7The seventh joined entity type.
T8The eighth joined entity type.
Exceptions
- NotSupportedException
The provider has no native multi-table
DELETE, or a join is not an INNERJoin.
Delete<TEntity>(IDataContext, TEntity)
Deletes the row identified by the declared key of entity in one command
(DELETE FROM ... WHERE <pk> = @p), using the mapping's [Key]/.Key().
public static int Delete<TEntity>(this IDataContext dataContext, TEntity entity)
Parameters
dataContextIDataContextThe context to execute against.
entityTEntityThe entity whose key identifies the row to delete.
Returns
- int
The number of deleted rows (0 or 1).
Type Parameters
TEntityThe mapped entity type.
Exceptions
- InvalidOperationException
The entity type declares no key.
Delete<T1, T2>(JoinedEntityBuilder<T1, T2>)
Deletes every row of the first table of a join that matches the join — a native multi-table
DELETE. The join condition (and any Where added to the joined builder) selects the
rows to remove. Only INNER Join joins are supported; outer/cross joins are rejected because
they change which rows are deleted. PostgreSQL renders DELETE ... USING; SQL Server, MySQL
and MariaDB render DELETE <alias> FROM ... JOIN. SQLite, ClickHouse and the in-memory
provider throw NotSupportedException.
public static int Delete<T1, T2>(this JoinedEntityBuilder<T1, T2> query)
Parameters
queryJoinedEntityBuilder<T1, T2>The joined query selecting the rows to delete.
Returns
- int
The number of deleted rows, as reported by the provider.
Type Parameters
T1The target entity type whose rows are deleted (the first table).
T2The joined entity type.
Exceptions
- NotSupportedException
The provider has no native multi-table
DELETE(SQLite, ClickHouse, in-memory), or a join is not an INNERJoin.
Delete<T1, T2, T3>(JoinedEntityBuilder<T1, T2, T3>)
Deletes every row of the first table of a three-table join that matches the join. See Delete<T1, T2>(JoinedEntityBuilder<T1, T2>) for the full contract.
public static int Delete<T1, T2, T3>(this JoinedEntityBuilder<T1, T2, T3> query)
Parameters
queryJoinedEntityBuilder<T1, T2, T3>The joined query selecting the rows to delete.
Returns
- int
The number of deleted rows.
Type Parameters
T1The target entity type whose rows are deleted.
T2The second joined entity type.
T3The third joined entity type.
Exceptions
- NotSupportedException
The provider has no native multi-table
DELETE, or a join is not an INNERJoin.
Delete<T1, T2, T3, T4>(JoinedEntityBuilder<T1, T2, T3, T4>)
Deletes every row of the first table of a four-table join that matches the join. See Delete<T1, T2>(JoinedEntityBuilder<T1, T2>) for the full contract.
public static int Delete<T1, T2, T3, T4>(this JoinedEntityBuilder<T1, T2, T3, T4> query)
Parameters
queryJoinedEntityBuilder<T1, T2, T3, T4>The joined query selecting the rows to delete.
Returns
- int
The number of deleted rows.
Type Parameters
T1The target entity type whose rows are deleted.
T2The second joined entity type.
T3The third joined entity type.
T4The fourth joined entity type.
Exceptions
- NotSupportedException
The provider has no native multi-table
DELETE, or a join is not an INNERJoin.
Delete<T1, T2, T3, T4, T5>(JoinedEntityBuilder<T1, T2, T3, T4, T5>)
Deletes every row of the first table of a five-table join that matches the join. See Delete<T1, T2>(JoinedEntityBuilder<T1, T2>) for the full contract.
public static int Delete<T1, T2, T3, T4, T5>(this JoinedEntityBuilder<T1, T2, T3, T4, T5> query)
Parameters
queryJoinedEntityBuilder<T1, T2, T3, T4, T5>The joined query selecting the rows to delete.
Returns
- int
The number of deleted rows.
Type Parameters
T1The target entity type whose rows are deleted.
T2The second joined entity type.
T3The third joined entity type.
T4The fourth joined entity type.
T5The fifth joined entity type.
Exceptions
- NotSupportedException
The provider has no native multi-table
DELETE, or a join is not an INNERJoin.
Delete<T1, T2, T3, T4, T5, T6>(JoinedEntityBuilder<T1, T2, T3, T4, T5, T6>)
Deletes every row of the first table of a six-table join that matches the join. See Delete<T1, T2>(JoinedEntityBuilder<T1, T2>) for the full contract.
public static int Delete<T1, T2, T3, T4, T5, T6>(this JoinedEntityBuilder<T1, T2, T3, T4, T5, T6> query)
Parameters
queryJoinedEntityBuilder<T1, T2, T3, T4, T5, T6>The joined query selecting the rows to delete.
Returns
- int
The number of deleted rows.
Type Parameters
T1The target entity type whose rows are deleted.
T2The second joined entity type.
T3The third joined entity type.
T4The fourth joined entity type.
T5The fifth joined entity type.
T6The sixth joined entity type.
Exceptions
- NotSupportedException
The provider has no native multi-table
DELETE, or a join is not an INNERJoin.
Delete<T1, T2, T3, T4, T5, T6, T7>(JoinedEntityBuilder<T1, T2, T3, T4, T5, T6, T7>)
Deletes every row of the first table of a seven-table join that matches the join. See Delete<T1, T2>(JoinedEntityBuilder<T1, T2>) for the full contract.
public static int Delete<T1, T2, T3, T4, T5, T6, T7>(this JoinedEntityBuilder<T1, T2, T3, T4, T5, T6, T7> query)
Parameters
queryJoinedEntityBuilder<T1, T2, T3, T4, T5, T6, T7>The joined query selecting the rows to delete.
Returns
- int
The number of deleted rows.
Type Parameters
T1The target entity type whose rows are deleted.
T2The second joined entity type.
T3The third joined entity type.
T4The fourth joined entity type.
T5The fifth joined entity type.
T6The sixth joined entity type.
T7The seventh joined entity type.
Exceptions
- NotSupportedException
The provider has no native multi-table
DELETE, or a join is not an INNERJoin.
Delete<T1, T2, T3, T4, T5, T6, T7, T8>(JoinedEntityBuilder<T1, T2, T3, T4, T5, T6, T7, T8>)
Deletes every row of the first table of an eight-table join that matches the join. See Delete<T1, T2>(JoinedEntityBuilder<T1, T2>) for the full contract.
public static int Delete<T1, T2, T3, T4, T5, T6, T7, T8>(this JoinedEntityBuilder<T1, T2, T3, T4, T5, T6, T7, T8> query)
Parameters
queryJoinedEntityBuilder<T1, T2, T3, T4, T5, T6, T7, T8>The joined query selecting the rows to delete.
Returns
- int
The number of deleted rows.
Type Parameters
T1The target entity type whose rows are deleted.
T2The second joined entity type.
T3The third joined entity type.
T4The fourth joined entity type.
T5The fifth joined entity type.
T6The sixth joined entity type.
T7The seventh joined entity type.
T8The eighth joined entity type.
Exceptions
- NotSupportedException
The provider has no native multi-table
DELETE, or a join is not an INNERJoin.
ExecuteProcedureAsync(IDataContext, string, CancellationToken)
Asynchronously executes a stored procedure without parameters. Convenience overload of ExecuteProcedureAsync(string, IReadOnlyList<ProcedureParameter>, CancellationToken).
public static Task<ProcedureResult> ExecuteProcedureAsync(this IDataContext dataContext, string name, CancellationToken cancellationToken = default)
Parameters
dataContextIDataContextThe context to execute against.
namestringThe procedure name, passed to the provider as-is.
cancellationTokenCancellationTokenCancels execution.
Returns
- Task<ProcedureResult>
A task producing the result, which must be disposed to release the reader and command.
Exceptions
- NotSupportedException
The context does not support stored procedures.
ExecuteRawAsync(IDataContext, string, CancellationToken)
Asynchronously executes a raw command text without parameters. Convenience overload of ExecuteRawAsync(string, IReadOnlyList<ProcedureParameter>, CancellationToken).
public static Task<ProcedureResult> ExecuteRawAsync(this IDataContext dataContext, string sql, CancellationToken cancellationToken = default)
Parameters
dataContextIDataContextThe context to execute against.
sqlstringThe command text to execute.
cancellationTokenCancellationTokenCancels execution.
Returns
- Task<ProcedureResult>
A task producing the result, which must be disposed to release the reader and command.
Exceptions
- NotSupportedException
The context does not support raw SQL execution.
FirstAsync<TResult>(IDataContext, IPreparedQueryCommand<TResult>, params object[]?)
Asynchronously returns the first row of the query.
public static Task<TResult> FirstAsync<TResult>(this IDataContext dataContext, IPreparedQueryCommand<TResult> preparedQueryCommand, params object[]? @params)
Parameters
dataContextIDataContextThe context to execute against.
preparedQueryCommandIPreparedQueryCommand<TResult>The prepared query to execute.
paramsobject[]Positional parameter values, in the order the SQL references them.
Returns
- Task<TResult>
The first materialized row.
Type Parameters
TResultThe projected element type.
Exceptions
- InvalidOperationException
The query returns no rows.
FirstOrDefaultAsync<TResult>(IDataContext, IPreparedQueryCommand<TResult>, params object[]?)
Asynchronously returns the first row of the query, or the default value of
TResult when the query returns no rows.
public static Task<TResult?> FirstOrDefaultAsync<TResult>(this IDataContext dataContext, IPreparedQueryCommand<TResult> preparedQueryCommand, params object[]? @params)
Parameters
dataContextIDataContextThe context to execute against.
preparedQueryCommandIPreparedQueryCommand<TResult>The prepared query to execute.
paramsobject[]Positional parameter values, in the order the SQL references them.
Returns
Type Parameters
TResultThe projected element type.
From(IDataContext, string)
Starts a query against a raw table (or CTE) name. Needed when the context is used through
IDataContext and therefore has no concrete From(string) instance method.
Columns are read through TableAlias accessors
(t.GetInt64("id") / t["id"].AsInt). The returned builder is generic so that the
full operator set (Where/Join/GroupBy/Having/OrderBy/
Limit/Select) is available, unlike the previous non-generic shape.
public static EntityBuilder<TableAlias> From(this IDataContext dataContext, string table)
Parameters
dataContextIDataContexttablestring
Returns
Exceptions
- ArgumentNullException
tableis null.- ArgumentException
tableis empty or consists only of white-space characters.
From(IDataContext, string, Action<FromOptions>)
Starts a query against a raw table (or CTE) name with per-query source options (a
TABLESAMPLE percentage, a ClickHouse SAMPLE ratio, or per-source table/index
hints). Columns are read through TableAlias accessors.
public static EntityBuilder<TableAlias> From(this IDataContext dataContext, string table, Action<FromOptions> options)
Parameters
dataContextIDataContextThe context to execute against.
tablestringThe table or CTE name.
optionsAction<FromOptions>Configures the primary source, for example
o => o.TableSample(10)oro => o.WithTableHint("nolock").
Returns
- EntityBuilder<TableAlias>
A builder for composing the query.
Exceptions
- ArgumentNullException
tableis null.- ArgumentException
tableis empty or consists only of white-space characters.
FromSql(IDataContext, string, object?)
Starts a query from a raw SQL fragment used as a composable FROM source: it is rendered as
(<sql>) AS alias and can be filtered, joined, projected, grouped and paged further.
Columns are read through TableAlias accessors (t["id"].AsInt).
parameters is an object whose public properties become the named parameters
referenced by the SQL (the same convention as WithSql). Requires a provider that supports
a derived-table FROM source (SupportsRawSqlSource).
public static EntityBuilder<TableAlias> FromSql(this IDataContext dataContext, string sql, object? parameters = null)
Parameters
dataContextIDataContextsqlstringparametersobject
Returns
Exceptions
- NotSupportedException
The active provider reports SupportsRawSqlSource as
false, or the context is the in-memory provider (which cannot evaluate raw SQL).
From<TResult>(IDataContext, CteReference<TResult>)
Starts the self-referencing read of a recursive common table expression inside the step callback
of AsRecursiveCte. The returned builder reads the CTE by its declared name and resolves
member access against the anchor's projection shape. A reference is only valid while its owning
step callback runs; using a captured or foreign reference (owner mismatch, even under the same
name) throws before any database command is built.
public static EntityBuilder<TResult> From<TResult>(this IDataContext dataContext, CteReference<TResult> reference)
Parameters
dataContextIDataContextThe context to execute against.
referenceCteReference<TResult>The self-reference handed to the step callback.
Returns
- EntityBuilder<TResult>
A builder reading the recursive CTE from within its own step.
Type Parameters
TResultThe recursive CTE's projection shape.
Exceptions
- ArgumentNullException
dataContextorreferenceis null.- InvalidOperationException
The reference is used outside its defining step (a captured or foreign reference).
From<TResult>(IDataContext, Cte<TResult>)
Starts a typed query from an ordinary CTE descriptor. The returned builder's primary source is
the CTE name carrying the descriptor's projection shape, so the CTE is read directly (no derived
SELECT wrapper) and every supported projection form resolves member access to the defining
query's output columns. The declaration and its reachable dependencies are attached to the
command, so a statement built over the source emits the required WITH. The descriptor is a
typed projection source, not a mapped entity. Recursion is not part of this API; ordinary CTEs only.
public static EntityBuilder<TResult> From<TResult>(this IDataContext dataContext, Cte<TResult> cte)
Parameters
dataContextIDataContextThe context to execute against.
cteCte<TResult>The descriptor returned by AsCte(string).
Returns
- EntityBuilder<TResult>
A builder for composing the query over the CTE.
Type Parameters
TResultThe CTE's projection shape.
Exceptions
- ArgumentNullException
dataContextorcteis null.
From<TResult>(IDataContext, EntityBuilder<TResult>)
Starts a new query builder that shares the source and definition of an existing builder.
public static EntityBuilder<TResult> From<TResult>(this IDataContext dataContext, EntityBuilder<TResult> builder)
Parameters
dataContextIDataContextThe context to execute against.
builderEntityBuilder<TResult>The builder to copy the query shape from.
Returns
- EntityBuilder<TResult>
A new builder bound to
dataContext.
Type Parameters
TResultThe projected element type.
From<TResult>(IDataContext, EntityBuilder<TResult>, Action<FromOptions>)
Starts a new query builder that shares the source and definition of an existing builder, with
per-source options. The values set on options (currently the derived-table
SubQueryHint) are copied into the returned builder; the options object is not retained.
public static EntityBuilder<TResult> From<TResult>(this IDataContext dataContext, EntityBuilder<TResult> builder, Action<FromOptions> options)
Parameters
dataContextIDataContextThe context to execute against.
builderEntityBuilder<TResult>The builder to copy the query shape from.
optionsAction<FromOptions>Configures the derived-table source, for example
o => o.WithSubQueryHint("NestLoop(t1)").
Returns
- EntityBuilder<TResult>
A new builder bound to
dataContext.
Type Parameters
TResultThe projected element type.
From<TResult>(IDataContext, QueryCommand<TResult>)
Starts a query from an existing QueryCommand<TResult> and returns a fluent builder over its definition.
public static EntityBuilder<TResult> From<TResult>(this IDataContext dataContext, QueryCommand<TResult> query)
Parameters
dataContextIDataContextThe context to execute against.
queryQueryCommand<TResult>The command whose definition drives the query.
Returns
- EntityBuilder<TResult>
A builder for composing the query further.
Type Parameters
TResultThe projected element type.
Remarks
A single-column scalar source — including a set-operation command such as
left.UnionAll(right) — materialises directly to List<T>. The read builds its own
one-column shape and does not reuse the process-wide select-list cache entry of the result type,
so a preceding scalar read that warmed that entry does not change the result. Before this
behaviour, the warm path reused a cached object-materialisation list and threw
QueryPreparationException ("Cannot get ctor from ..."), while the cold path
succeeded. A derived source with more than one column still requires an explicit outer
Select.
From<TResult>(IDataContext, QueryCommand<TResult>, Action<FromOptions>)
Starts a query from an existing QueryCommand<TResult> with per-source options. The
values set on options (currently the derived-table SubQueryHint) are
copied into the returned builder; the options object is not retained.
public static EntityBuilder<TResult> From<TResult>(this IDataContext dataContext, QueryCommand<TResult> query, Action<FromOptions> options)
Parameters
dataContextIDataContextThe context to execute against.
queryQueryCommand<TResult>The command whose definition drives the query.
optionsAction<FromOptions>Configures the derived-table source, for example
o => o.WithSubQueryHint("NestLoop(t1)").
Returns
- EntityBuilder<TResult>
A builder for composing the query further.
Type Parameters
TResultThe projected element type.
From<TResult>(IDataContext, TempTableSource<TResult>)
Starts a query over a lazy temporary table created by
AsTempTable<TResult>(QueryCommand<TResult>, CreateTableOptions?).
Executing the returned query runs one batch on a single session — it drops and re-creates the
temporary table from the source query, then reads it — so the table is always freshly
materialised and the read never depends on connection pinning. Columns are read through
TableAlias accessors (t.GetInt32("id")).
The form is available on PostgreSQL, SQLite, MySQL and MariaDB, the providers whose dialect can
express a temporary CREATE TABLE ... AS SELECT. SQL Server, ClickHouse and the in-memory
context reject it when the query renders.
public static EntityBuilder<TableAlias> From<TResult>(this IDataContext dataContext, TempTableSource<TResult> tempTable)
Parameters
dataContextIDataContextThe context to execute against.
tempTableTempTableSource<TResult>The lazy source to materialise and read.
Returns
- EntityBuilder<TableAlias>
A builder for composing the query over the temporary table.
Type Parameters
TResultThe source query's projected row type.
Exceptions
- ArgumentNullException
dataContextortempTableis null.- NotSupportedException
The context cannot execute a batch and therefore cannot materialise a temporary table (the in-memory provider).
From<T>(IDataContext, Action<EntityMetadataBuilder<T>>?)
Starts a query over the mapping of T and returns its fluent builder.
The type's metadata is resolved lazily and cached per process; configEntity
therefore runs only on the first call for T.
public static EntityBuilder<T> From<T>(this IDataContext dataContext, Action<EntityMetadataBuilder<T>>? configEntity = null)
Parameters
dataContextIDataContextconfigEntityAction<EntityMetadataBuilder<T>>
Returns
Type Parameters
T
From<T>(IDataContext, Action<FromOptions>, Action<EntityMetadataBuilder<T>>?)
Starts a query over the mapping of T with per-query source options. The
values set on options (a TABLESAMPLE percentage, a ClickHouse
SAMPLE ratio, or per-source table/index hints) are copied into the returned builder; the
options object is not retained.
The type's metadata is resolved exactly like From<T>(IDataContext, Action<EntityMetadataBuilder<T>>?).
public static EntityBuilder<T> From<T>(this IDataContext dataContext, Action<FromOptions> options, Action<EntityMetadataBuilder<T>>? configEntity = null)
Parameters
dataContextIDataContextThe context to execute against.
optionsAction<FromOptions>Configures the primary source, for example
o => o.TableSample(10)oro => o.WithTableHint("nolock").configEntityAction<EntityMetadataBuilder<T>>Optional mapping configuration, run only when the type is first mapped.
Returns
- EntityBuilder<T>
A builder for composing the query.
Type Parameters
TThe mapped entity type.
From<T>(IDataContext, Expression<Func<EntityBuilder<T>>>)
Starts a query from a runtime table-valued-function descriptor supplied as an expression
source, for example ctx.From(() => Db.MyTvf(42)). The lambda is required: a direct
Db.MyTvf(42) call would pass an argument value and lose the expression, so only the lambda
carries the call node whose arguments are rendered/parameterised like any other SQL expression.
The factory must return TvfEntityBuilder<T> for the same row type, and its metadata
must not depend on the argument values. The argument expressions are kept untouched — a member of
an outer row stays an outer-column reference, never an evaluated CLR value. Builder operations
composed on the descriptor in the same lambda (Where, ordering and other
builder-returning operations) are re-applied in their original order, so the source, its
arguments and the composed operations all reach the query. A captured descriptor or any other
shape without the original call expression is rejected with
NotSupportedException.
public static EntityBuilder<T> From<T>(this IDataContext dataContext, Expression<Func<EntityBuilder<T>>> source)
Parameters
dataContextIDataContextThe context to execute against.
sourceExpression<Func<EntityBuilder<T>>>The expression that calls the runtime factory, for example
() => Db.MyTvf(42).
Returns
- EntityBuilder<T>
A builder for composing the query over the function.
Type Parameters
TThe mapped row type the function returns, i.e. the result type of the composed chain.
Exceptions
- ArgumentNullException
dataContextorsourceis null.- NotSupportedException
The expression is not a direct runtime-factory call or lost its argument provenance.
From<T>(IDataContext, Expression<Func<EntityBuilder<T>>>, Action<FromOptions>)
Starts a query from a runtime table-valued-function descriptor supplied as an expression source, with per-source options. See From<T>(IDataContext, Expression<Func<EntityBuilder<T>>>).
public static EntityBuilder<T> From<T>(this IDataContext dataContext, Expression<Func<EntityBuilder<T>>> source, Action<FromOptions> configure)
Parameters
dataContextIDataContextThe context to execute against.
sourceExpression<Func<EntityBuilder<T>>>The expression that calls the runtime factory.
configureAction<FromOptions>Configures the source placement, for example
o => o.WithSubQueryHint("NestLoop(t1)").
Returns
- EntityBuilder<T>
A builder for composing the query over the function.
Type Parameters
TThe mapped row type the function returns, i.e. the result type of the composed chain.
Exceptions
- ArgumentNullException
dataContext,sourceorconfigureis null.- NotSupportedException
The expression is not a direct runtime-factory call or lost its argument provenance.
SingleAsync<TResult>(IDataContext, IPreparedQueryCommand<TResult>, params object[]?)
Asynchronously returns the only row of the query.
public static Task<TResult> SingleAsync<TResult>(this IDataContext dataContext, IPreparedQueryCommand<TResult> preparedQueryCommand, params object[]? @params)
Parameters
dataContextIDataContextThe context to execute against.
preparedQueryCommandIPreparedQueryCommand<TResult>The prepared query to execute.
paramsobject[]Positional parameter values, in the order the SQL references them.
Returns
- Task<TResult>
The single materialized row.
Type Parameters
TResultThe projected element type.
Exceptions
- InvalidOperationException
The query returns no rows or more than one row.
SingleOrDefaultAsync<TResult>(IDataContext, IPreparedQueryCommand<TResult>, params object[]?)
Asynchronously returns the only row of the query, or the default value of
TResult when the query returns no rows.
public static Task<TResult?> SingleOrDefaultAsync<TResult>(this IDataContext dataContext, IPreparedQueryCommand<TResult> preparedQueryCommand, params object[]? @params)
Parameters
dataContextIDataContextThe context to execute against.
preparedQueryCommandIPreparedQueryCommand<TResult>The prepared query to execute.
paramsobject[]Positional parameter values, in the order the SQL references them.
Returns
Type Parameters
TResultThe projected element type.
Exceptions
- InvalidOperationException
The query returns more than one row.
ToListAsync<TResult>(IDataContext, IPreparedQueryCommand<TResult>, params object[]?)
Asynchronously executes the query and materializes every row into a new list.
public static Task<List<TResult>> ToListAsync<TResult>(this IDataContext dataContext, IPreparedQueryCommand<TResult> preparedQueryCommand, params object[]? @params)
Parameters
dataContextIDataContextThe context to execute against.
preparedQueryCommandIPreparedQueryCommand<TResult>The prepared query to execute.
paramsobject[]Positional parameter values, in the order the SQL references them.
Returns
Type Parameters
TResultThe projected element type.
ToList<TResult>(IDataContext, IPreparedQueryCommand<TResult>)
Synchronously executes the query and materializes every row into a new list, using no parameters.
public static List<TResult> ToList<TResult>(this IDataContext dataContext, IPreparedQueryCommand<TResult> preparedQueryCommand)
Parameters
dataContextIDataContextThe context to execute against.
preparedQueryCommandIPreparedQueryCommand<TResult>The prepared query to execute.
Returns
- List<TResult>
A list containing the materialized rows; empty when the query matches nothing.
Type Parameters
TResultThe projected element type.
ToSql<T1, T2>(JoinedEntityBuilder<T1, T2>)
Renders the multi-table DELETE the joined query would execute, without executing it. See Delete<T1, T2>(JoinedEntityBuilder<T1, T2>) for the full contract.
public static string ToSql<T1, T2>(this JoinedEntityBuilder<T1, T2> query)
Parameters
queryJoinedEntityBuilder<T1, T2>The joined query selecting the rows to delete.
Returns
- string
The rendered SQL text.
Type Parameters
T1The target entity type whose rows are deleted.
T2The joined entity type.
Exceptions
- NotSupportedException
The provider has no native multi-table
DELETE, or a join is not an INNERJoin.
ToSql<T1, T2, T3>(JoinedEntityBuilder<T1, T2, T3>)
Renders the multi-table DELETE a three-table join would execute. See Delete<T1, T2>(JoinedEntityBuilder<T1, T2>) for the full contract.
public static string ToSql<T1, T2, T3>(this JoinedEntityBuilder<T1, T2, T3> query)
Parameters
queryJoinedEntityBuilder<T1, T2, T3>The joined query selecting the rows to delete.
Returns
- string
The rendered SQL text.
Type Parameters
T1The target entity type whose rows are deleted.
T2The second joined entity type.
T3The third joined entity type.
Exceptions
- NotSupportedException
The provider has no native multi-table
DELETE, or a join is not an INNERJoin.
ToSql<T1, T2, T3, T4>(JoinedEntityBuilder<T1, T2, T3, T4>)
Renders the multi-table DELETE a four-table join would execute. See Delete<T1, T2>(JoinedEntityBuilder<T1, T2>) for the full contract.
public static string ToSql<T1, T2, T3, T4>(this JoinedEntityBuilder<T1, T2, T3, T4> query)
Parameters
queryJoinedEntityBuilder<T1, T2, T3, T4>The joined query selecting the rows to delete.
Returns
- string
The rendered SQL text.
Type Parameters
T1The target entity type whose rows are deleted.
T2The second joined entity type.
T3The third joined entity type.
T4The fourth joined entity type.
Exceptions
- NotSupportedException
The provider has no native multi-table
DELETE, or a join is not an INNERJoin.
ToSql<T1, T2, T3, T4, T5>(JoinedEntityBuilder<T1, T2, T3, T4, T5>)
Renders the multi-table DELETE a five-table join would execute. See Delete<T1, T2>(JoinedEntityBuilder<T1, T2>) for the full contract.
public static string ToSql<T1, T2, T3, T4, T5>(this JoinedEntityBuilder<T1, T2, T3, T4, T5> query)
Parameters
queryJoinedEntityBuilder<T1, T2, T3, T4, T5>The joined query selecting the rows to delete.
Returns
- string
The rendered SQL text.
Type Parameters
T1The target entity type whose rows are deleted.
T2The second joined entity type.
T3The third joined entity type.
T4The fourth joined entity type.
T5The fifth joined entity type.
Exceptions
- NotSupportedException
The provider has no native multi-table
DELETE, or a join is not an INNERJoin.
ToSql<T1, T2, T3, T4, T5, T6>(JoinedEntityBuilder<T1, T2, T3, T4, T5, T6>)
Renders the multi-table DELETE a six-table join would execute. See Delete<T1, T2>(JoinedEntityBuilder<T1, T2>) for the full contract.
public static string ToSql<T1, T2, T3, T4, T5, T6>(this JoinedEntityBuilder<T1, T2, T3, T4, T5, T6> query)
Parameters
queryJoinedEntityBuilder<T1, T2, T3, T4, T5, T6>The joined query selecting the rows to delete.
Returns
- string
The rendered SQL text.
Type Parameters
T1The target entity type whose rows are deleted.
T2The second joined entity type.
T3The third joined entity type.
T4The fourth joined entity type.
T5The fifth joined entity type.
T6The sixth joined entity type.
Exceptions
- NotSupportedException
The provider has no native multi-table
DELETE, or a join is not an INNERJoin.
ToSql<T1, T2, T3, T4, T5, T6, T7>(JoinedEntityBuilder<T1, T2, T3, T4, T5, T6, T7>)
Renders the multi-table DELETE a seven-table join would execute. See Delete<T1, T2>(JoinedEntityBuilder<T1, T2>) for the full contract.
public static string ToSql<T1, T2, T3, T4, T5, T6, T7>(this JoinedEntityBuilder<T1, T2, T3, T4, T5, T6, T7> query)
Parameters
queryJoinedEntityBuilder<T1, T2, T3, T4, T5, T6, T7>The joined query selecting the rows to delete.
Returns
- string
The rendered SQL text.
Type Parameters
T1The target entity type whose rows are deleted.
T2The second joined entity type.
T3The third joined entity type.
T4The fourth joined entity type.
T5The fifth joined entity type.
T6The sixth joined entity type.
T7The seventh joined entity type.
Exceptions
- NotSupportedException
The provider has no native multi-table
DELETE, or a join is not an INNERJoin.
ToSql<T1, T2, T3, T4, T5, T6, T7, T8>(JoinedEntityBuilder<T1, T2, T3, T4, T5, T6, T7, T8>)
Renders the multi-table DELETE an eight-table join would execute. See Delete<T1, T2>(JoinedEntityBuilder<T1, T2>) for the full contract.
public static string ToSql<T1, T2, T3, T4, T5, T6, T7, T8>(this JoinedEntityBuilder<T1, T2, T3, T4, T5, T6, T7, T8> query)
Parameters
queryJoinedEntityBuilder<T1, T2, T3, T4, T5, T6, T7, T8>The joined query selecting the rows to delete.
Returns
- string
The rendered SQL text.
Type Parameters
T1The target entity type whose rows are deleted.
T2The second joined entity type.
T3The third joined entity type.
T4The fourth joined entity type.
T5The fifth joined entity type.
T6The sixth joined entity type.
T7The seventh joined entity type.
T8The eighth joined entity type.
Exceptions
- NotSupportedException
The provider has no native multi-table
DELETE, or a join is not an INNERJoin.
UpdateAsync<TEntity>(IDataContext, TEntity, CancellationToken)
Asynchronously updates the row identified by the declared key of entity in one
command, using the mapping's [Key]/.Key().
public static Task<int> UpdateAsync<TEntity>(this IDataContext dataContext, TEntity entity, CancellationToken cancellationToken = default)
Parameters
dataContextIDataContextThe context to execute against.
entityTEntityThe entity whose key identifies the row and whose values are written.
cancellationTokenCancellationTokenCancels execution.
Returns
Type Parameters
TEntityThe mapped entity type.
Exceptions
- InvalidOperationException
The entity type declares no key.
- NotSupportedException
The context does not support data modification (the in-memory provider), or the provider cannot express
UPDATE(ClickHouse).
Update<TEntity>(IDataContext, TEntity)
Updates the row identified by the declared key of entity in one command
(UPDATE ... SET ... WHERE <pk> = @p), writing every non-key, non-identity,
non-computed column. Uses the mapping's [Key]/.Key().
public static int Update<TEntity>(this IDataContext dataContext, TEntity entity)
Parameters
dataContextIDataContextThe context to execute against.
entityTEntityThe entity whose key identifies the row and whose values are written.
Returns
- int
The number of updated rows (0 or 1).
Type Parameters
TEntityThe mapped entity type.
Exceptions
- InvalidOperationException
The entity type declares no key.
- NotSupportedException
The context does not support data modification (the in-memory provider), or the provider cannot express
UPDATE(ClickHouse).
With(IDataContext, string, QueryCommand)
Starts a CTE scope with a single non-recursive declaration.
public static CteQuery With(this IDataContext dataContext, string name, QueryCommand query)
Parameters
dataContextIDataContextnamestringqueryQueryCommand
Returns
WithRecursive(IDataContext, string, QueryCommand, int?)
Starts a CTE scope with a single recursive declaration. maxRecursion
is rendered only by dialects that expose a depth option (SQL Server).
public static CteQuery WithRecursive(this IDataContext dataContext, string name, QueryCommand query, int? maxRecursion = null)
Parameters
dataContextIDataContextnamestringqueryQueryCommandmaxRecursionint?
Returns
With<TProjection, TResult>(IDataContext, string, DeleteJoinReturningBuilder<TProjection, TResult>)
Starts a CTE scope whose first declaration is a data-modifying common table expression whose body
is a multi-table DELETE ... USING ... RETURNING. See
With<TEntity, TResult>(IDataContext, string, DeleteReturningBuilder<TEntity, TResult>)
for the full contract.
public static MutationCteQuery<TResult> With<TProjection, TResult>(this IDataContext dataContext, string name, DeleteJoinReturningBuilder<TProjection, TResult> delete)
Parameters
dataContextIDataContextThe context to execute against.
namestringThe name the data-modifying CTE is declared under.
deleteDeleteJoinReturningBuilder<TProjection, TResult>The returning multi-table delete that forms the CTE body.
Returns
- MutationCteQuery<TResult>
A scope that reads the mutation's returned rows and can declare more read CTEs.
Type Parameters
TProjectionThe positional join projection (
Projection<T1, ...>).TResultThe row shape the CTE returns through
RETURNING.
Exceptions
- NotSupportedException
The active provider does not accept a data-modifying CTE body (only PostgreSQL does).
With<TEntity, TResult>(IDataContext, string, DeleteReturningBuilder<TEntity, TResult>)
Starts a CTE scope whose first declaration is a data-modifying common table expression whose body
is a single-table DELETE ... RETURNING. See
With<TEntity, TResult>(IDataContext, string, UpdateReturningBuilder<TEntity, TResult>)
for the full contract.
public static MutationCteQuery<TResult> With<TEntity, TResult>(this IDataContext dataContext, string name, DeleteReturningBuilder<TEntity, TResult> delete)
Parameters
dataContextIDataContextThe context to execute against.
namestringThe name the data-modifying CTE is declared under.
deleteDeleteReturningBuilder<TEntity, TResult>The returning delete that forms the CTE body.
Returns
- MutationCteQuery<TResult>
A scope that reads the mutation's returned rows and can declare more read CTEs.
Type Parameters
TEntityThe mapped entity type whose rows are removed by the CTE body.
TResultThe row shape the CTE returns through
RETURNING.
Exceptions
- NotSupportedException
The active provider does not accept a data-modifying CTE body (only PostgreSQL does).
With<TEntity, TResult>(IDataContext, string, InsertReturningBuilder<TEntity, TResult>)
Starts a CTE scope whose first declaration is a data-modifying common table expression: the
insert runs as the CTE body and its RETURNING rows are read through
From(string). The scope is typed by
TResult so the returned rows can be filtered, joined and projected.
Example: ctx.With("ins", ctx.CreateInsertBuilder<Order>().Values(o).Returning(x => new { x.Id }))
.From("ins").Select(r => new { r.Id }).
public static MutationCteQuery<TResult> With<TEntity, TResult>(this IDataContext dataContext, string name, InsertReturningBuilder<TEntity, TResult> insert)
Parameters
dataContextIDataContextThe context to execute against.
namestringThe name the data-modifying CTE is declared under.
insertInsertReturningBuilder<TEntity, TResult>The returning insert that forms the CTE body.
Returns
- MutationCteQuery<TResult>
A scope that reads the mutation's returned rows and can declare more read CTEs.
Type Parameters
TEntityThe mapped entity type inserted by the CTE body.
TResultThe row shape the CTE returns through
RETURNING.
Exceptions
- NotSupportedException
The active provider does not accept a data-modifying CTE body (only PostgreSQL does), or the context is the read-only in-memory provider.
With<TProjection, TResult>(IDataContext, string, UpdateJoinReturningBuilder<TProjection, TResult>)
Starts a CTE scope whose first declaration is a data-modifying common table expression whose body
is a multi-table UPDATE ... FROM ... RETURNING. See
With<TEntity, TResult>(IDataContext, string, UpdateReturningBuilder<TEntity, TResult>)
for the full contract.
public static MutationCteQuery<TResult> With<TProjection, TResult>(this IDataContext dataContext, string name, UpdateJoinReturningBuilder<TProjection, TResult> update)
Parameters
dataContextIDataContextThe context to execute against.
namestringThe name the data-modifying CTE is declared under.
updateUpdateJoinReturningBuilder<TProjection, TResult>The returning multi-table update that forms the CTE body.
Returns
- MutationCteQuery<TResult>
A scope that reads the mutation's returned rows and can declare more read CTEs.
Type Parameters
TProjectionThe positional join projection (
Projection<T1, ...>).TResultThe row shape the CTE returns through
RETURNING.
Exceptions
- NotSupportedException
The active provider does not accept a data-modifying CTE body (only PostgreSQL does).
With<TEntity, TResult>(IDataContext, string, UpdateReturningBuilder<TEntity, TResult>)
Starts a CTE scope whose first declaration is a data-modifying common table expression whose body
is a single-table UPDATE ... RETURNING: the update runs as the CTE body and its returned
rows are read through From(string). Only PostgreSQL accepts
a data-modifying CTE body.
public static MutationCteQuery<TResult> With<TEntity, TResult>(this IDataContext dataContext, string name, UpdateReturningBuilder<TEntity, TResult> update)
Parameters
dataContextIDataContextThe context to execute against.
namestringThe name the data-modifying CTE is declared under.
updateUpdateReturningBuilder<TEntity, TResult>The returning update that forms the CTE body.
Returns
- MutationCteQuery<TResult>
A scope that reads the mutation's returned rows and can declare more read CTEs.
Type Parameters
TEntityThe mapped entity type whose rows are updated by the CTE body.
TResultThe row shape the CTE returns through
RETURNING.
Exceptions
- NotSupportedException
The active provider does not accept a data-modifying CTE body (only PostgreSQL does).