DmlConnectionExtensions
Namespace: MJCZone.DapperMatic.Dml
Assembly: MJCZone.DapperMatic
Summary
Reads and writes the rows of model tables: the classes DapperMatic builds tables from.
static public
Contents
Methods (64)
Methods
| Method | Summary |
|---|---|
| AsCallerAsync | Runs statements on the connection as a caller, held to the policies as the web API holds requests: s... |
| InSchema | Uses a schema for every model, such as a tenant's, instead of each model's own. |
| WithTableName | Uses a table for a model, such as an archive table, instead of the model's own. |
| From | Starts a query of a model's rows, refined with <c>Where</c>, <c>OrderBy</c>,... |
| InsertAsync | Inserts a row. |
| InsertManyAsync | Inserts rows, several to a statement, all or none. |
| UpdateAsync | Updates every column of a row but its key, by its key. |
| DeleteAsync | Deletes a row, by its key. |
| DeleteByIdAsync | Deletes the row with a key. |
| SingleByIdAsync | Reads the row with a key. |
| SelectByIdsAsync | Reads the rows with any of the given keys, in no particular order. |
| SelectAsync | Reads the rows that match a condition, or every row. |
| SingleAsync | Reads the one row that matches a condition. |
| FirstAsync | Reads the first row that matches a condition, in key order. |
| CountAsync | Counts the rows that match a condition, or every row. |
| ExistsAsync | Tells whether any row matches a condition, or whether the table has any rows. |
| UpdateAsync | Sets columns of the rows that match a condition. |
| DeleteAsync | Deletes the rows that match a condition. |
| DeleteAllAsync | Deletes every row. |
| WithTableName | Uses a table for a model, such as an archive table, instead of the model's own. |
| InsertAsync | Inserts a row. |
| InsertManyAsync | Inserts rows, several to a statement, all or none. |
| UpdateAsync | Updates every column of a row but its key, by its key. |
| DeleteAsync | Deletes a row, by its key. |
| DeleteByIdAsync | Deletes the row with a key. |
| SingleByIdAsync | Reads the row with a key. |
| SelectByIdsAsync | Reads the rows with any of the given keys, in no particular order. |
| SelectAsync | Reads every row of a model. |
| FirstAsync | Reads the row of a model with the lowest key. |
| CountAsync | Counts the rows of a model. |
| ExistsAsync | Tells whether a model's table has any rows. |
| DeleteAllAsync | Deletes every row. |
| PatchAsync | Sets the columns a patch has values for, leaving the rest unchanged. |
| PatchAsync | Sets the columns a patch has values for in the row with the key the patch holds, leaving the rest un... |
| UpsertAsync | Inserts a row, or updates every column of the row with its key if there is one. |
| UpsertAsync | Inserts a row, or updates every column of the row with its key if there is one. |
| UpsertAsync | Inserts a row, or updates the row it conflicts with as the options say. |
| InsertIfAbsentAsync | Inserts a row unless a row with its primary key exists. |
| InsertIfAbsentAsync | Inserts a row unless a row with the same values in some columns exists. |
| InsertIfAbsentAsync | Inserts a row unless a row with its primary key exists. |
| BulkInsertAsync | Inserts rows in bulk, all or none, through the provider's native bulk path, or multi-row VALUES with... |
| BulkInsertAsync | Inserts rows in bulk, all or none, with options. |
| BulkInsertAsync | Inserts rows of a model known at run time in bulk, all or none. |
| BulkInsertAsync | Inserts rows of a model known at run time in bulk, all or none, with options. |
| BulkUpsertAsync | Inserts rows in bulk, or updates the rows with their primary keys, all or none, through a staging ta... |
| BulkUpsertAsync | Inserts rows in bulk, or updates the rows they conflict with as the options say, all or none. |
| BulkUpsertAsync | Inserts rows of a model known at run time in bulk, or updates the rows with their primary keys, all ... |
| LoadAsync | Loads relations onto rows already read, by one query per relation and batch of the rows' keys. |
| ForTenant | Reads and writes only a tenant's rows of models with a <c>[DmTenantKey]</c>, and sets it... |
| AllTenants | Reads and writes every tenant's rows of models with a <c>[DmTenantKey]</c>. |
| WithUser | Sets the user <c>[DmCreatedBy]</c> and <c>[DmUpdatedBy]</c> record. |
| IncludeDeleted | Reads deleted rows of models with a <c>[DmSoftDelete]</c> too. |
| OnlyDeleted | Reads only the deleted rows of the models a statement reads. |
| HardDeleteAsync | Removes a row by its key, even of a model with a <c>[DmSoftDelete]</c>. |
| HardDeleteAsync | Removes a row of a model known at run time by its key, even of a model with a <c>[DmSoftDelete |
| HardDeleteByIdAsync | Removes the row with a key, even of a model with a <c>[DmSoftDelete]</c>. |
| HardDeleteByIdAsync | Removes the row of a model known at run time with a key, even of a model with a <c>[DmSoftDele... |
| HardDeleteAsync | Removes the rows that match a condition, deleted or not. |
| HardDeleteAllAsync | Removes every row, deleted or not. |
| HardDeleteAllAsync | Removes every row of a model known at run time, deleted or not. |
| GetType | |
| ToString | |
| Equals | |
| GetHashCode |
AsCallerAsync
Runs statements on the connection as a caller, held to the policies as the web API holds requests: see CancellationToken).
Task<DmScope> AsCallerAsync(
IDbConnection db,
DmAccessContext access,
DmPolicy} policies,
string datasourceId,
CancellationToken cancellationToken)Parameters
- db (IDbConnection) - The connection.
- access (DmAccessContext) - The caller: who they are, their tenant and values.
- policies (DmPolicy}) - The policies, such as those of the web API.
- datasourceId (string) - The datasource the policies know the connection by.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<DmScope>
A scope run as the caller.
InSchema
Uses a schema for every model, such as a tenant's, instead of each model's own.
DmScope InSchema(IDbConnection db, string schemaName)Parameters
- db (IDbConnection) - The connection.
- schemaName (string) - The schema.
Returns
Type: DmScope
A scope using it, with the same methods as the connection.
WithTableName
Uses a table for a model, such as an archive table, instead of the model's own.
DmScope WithTableName(IDbConnection db, string tableName)Parameters
- db (IDbConnection) - The connection.
- tableName (string) - The table.
Returns
Type: DmScope
A scope using it, with the same methods as the connection.
From
Starts a query of a model's rows, refined with <c>Where</c>, <c>OrderBy</c>, <c>Skip</c>, <c>Take</c> and <c>Select</c>.
DmQuery<T> From(IDbConnection db)Parameters
- db (IDbConnection) - The connection.
Returns
Type: DmQuery<T>
A query of every row, which runs only when one of its methods is called.
InsertAsync
Inserts a row.
Task<object?> InsertAsync(
IDbConnection db,
``0 row,
IDbTransaction tx,
CancellationToken cancellationToken)Parameters
- db (IDbConnection) - The connection.
- row (``0) - The row.
- tx (IDbTransaction) - The transaction to use, or null.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<object?>
The row's key: the value the database generated for an auto-increment key, which is also set on the row; the
key the row carries otherwise; or null for a composite key or no key.
InsertManyAsync
Inserts rows, several to a statement, all or none.
Task<int> InsertManyAsync(
IDbConnection db,
IEnumerable{``0} rows,
IDbTransaction tx,
CancellationToken cancellationToken)Parameters
- db (IDbConnection) - The connection.
- rows (IEnumerable{``0}) - The rows.
- tx (IDbTransaction) - The transaction to use, or null.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<int>
The number of rows inserted.
UpdateAsync
Updates every column of a row but its key, by its key.
Task<int> UpdateAsync(
IDbConnection db,
``0 row,
IDbTransaction tx,
CancellationToken cancellationToken)Parameters
- db (IDbConnection) - The connection.
- row (``0) - The row.
- tx (IDbTransaction) - The transaction to use, or null.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<int>
The number of rows updated: 1, or 0 if no row has the key.
DeleteAsync
Deletes a row, by its key.
Task<int> DeleteAsync(
IDbConnection db,
``0 row,
IDbTransaction tx,
CancellationToken cancellationToken)Parameters
- db (IDbConnection) - The connection.
- row (``0) - The row.
- tx (IDbTransaction) - The transaction to use, or null.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<int>
The number of rows deleted: 1, or 0 if no row has the key.
DeleteByIdAsync
Deletes the row with a key.
Task<int> DeleteByIdAsync(
IDbConnection db,
object key,
IDbTransaction tx,
CancellationToken cancellationToken)Parameters
- db (IDbConnection) - The connection.
- key (object) - The key: its value, or for a composite key an object or tuple holding each key property.
- tx (IDbTransaction) - The transaction to use, or null.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<int>
The number of rows deleted: 1, or 0 if no row has the key.
SingleByIdAsync
Reads the row with a key.
Task<T?> SingleByIdAsync(
IDbConnection db,
object key,
IDbTransaction tx,
CancellationToken cancellationToken)Parameters
- db (IDbConnection) - The connection.
- key (object) - The key: its value, or for a composite key an object or tuple holding each key property.
- tx (IDbTransaction) - The transaction to use, or null.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<T?>
The row, or null if there is none.
SelectByIdsAsync
Reads the rows with any of the given keys, in no particular order.
Task<List<T>> SelectByIdsAsync(
IDbConnection db,
Object} keys,
IDbTransaction tx,
CancellationToken cancellationToken)Parameters
- db (IDbConnection) - The connection.
- keys (Object}) - The keys.
- tx (IDbTransaction) - The transaction to use, or null.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<List<T>>
The rows found.
SelectAsync
Reads the rows that match a condition, or every row.
Task<List<T>> SelectAsync(
IDbConnection db,
Func{``0 where,
Boolean}} tx,
IDbTransaction cancellationToken)Parameters
- db (IDbConnection) - The connection.
- where (Func{``0) - , or null for every row.
- tx (Boolean}}) - The transaction to use, or null.
- cancellationToken (IDbTransaction) - The cancellation token.
Returns
Type: Task<List<T>>
The rows, in no particular order.
SingleAsync
Reads the one row that matches a condition.
Task<T?> SingleAsync(
IDbConnection db,
Func{``0 where,
Boolean}} tx,
IDbTransaction cancellationToken)Parameters
- db (IDbConnection) - The connection.
- where (Func{``0) - The condition.
- tx (Boolean}}) - The transaction to use, or null.
- cancellationToken (IDbTransaction) - The cancellation token.
Returns
Type: Task<T?>
The row, or null if no row matches.
FirstAsync
Reads the first row that matches a condition, in key order.
Task<T?> FirstAsync(
IDbConnection db,
Func{``0 where,
Boolean}} tx,
IDbTransaction cancellationToken)Parameters
- db (IDbConnection) - The connection.
- where (Func{``0) - The condition, or null for any row.
- tx (Boolean}}) - The transaction to use, or null.
- cancellationToken (IDbTransaction) - The cancellation token.
Returns
Type: Task<T?>
The row with the lowest key that matches, any matching row for a model with no key, or null.
CountAsync
Counts the rows that match a condition, or every row.
Task<long> CountAsync(
IDbConnection db,
Func{``0 where,
Boolean}} tx,
IDbTransaction cancellationToken)Parameters
- db (IDbConnection) - The connection.
- where (Func{``0) - The condition, or null for every row.
- tx (Boolean}}) - The transaction to use, or null.
- cancellationToken (IDbTransaction) - The cancellation token.
Returns
Type: Task<long>
The number of rows.
ExistsAsync
Tells whether any row matches a condition, or whether the table has any rows.
Task<bool> ExistsAsync(
IDbConnection db,
Func{``0 where,
Boolean}} tx,
IDbTransaction cancellationToken)Parameters
- db (IDbConnection) - The connection.
- where (Func{``0) - The condition, or null for any row.
- tx (Boolean}}) - The transaction to use, or null.
- cancellationToken (IDbTransaction) - The cancellation token.
Returns
Type: Task<bool>
True if a row matches.
UpdateAsync
Sets columns of the rows that match a condition.
Task<int> UpdateAsync(
IDbConnection db,
Func{``0 set,
``0}} where,
Func{``0 tx,
Boolean}} cancellationToken)Parameters
db (IDbConnection) - The connection.
set (Func{``0) - .
where (``0}}) - .
tx (Func{``0) - The transaction to use, or null.
cancellationToken (Boolean}}) - The cancellation token.
Returns
Type: Task<int>
The number of rows updated.
DeleteAsync
Deletes the rows that match a condition.
Task<int> DeleteAsync(
IDbConnection db,
Func{``0 where,
Boolean}} tx,
IDbTransaction cancellationToken)Parameters
- db (IDbConnection) - The connection.
- where (Func{``0) - .
- tx (Boolean}}) - The transaction to use, or null.
- cancellationToken (IDbTransaction) - The cancellation token.
Returns
Type: Task<int>
The number of rows deleted.
DeleteAllAsync
Deletes every row.
Task<int> DeleteAllAsync(
IDbConnection db,
IDbTransaction tx,
CancellationToken cancellationToken)Parameters
- db (IDbConnection) - The connection.
- tx (IDbTransaction) - The transaction to use, or null.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<int>
The number of rows deleted.
WithTableName
Uses a table for a model, such as an archive table, instead of the model's own.
DmScope WithTableName(IDbConnection db, Type type, string tableName)Parameters
- db (IDbConnection) - The connection.
- type (Type) - The model type.
- tableName (string) - The table.
Returns
Type: DmScope
A scope using it, with the same methods as the connection.
InsertAsync
Inserts a row.
Task<object?> InsertAsync(
IDbConnection db,
Type type,
object row,
IDbTransaction tx,
CancellationToken cancellationToken)Parameters
- db (IDbConnection) - The connection.
- type (Type) - The model type.
- row (object) - The row.
- tx (IDbTransaction) - The transaction to use, or null.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<object?>
The row's key: the value the database generated for an auto-increment key, which is also set on the row; the key the row carries otherwise; or null for a composite key or no key.
InsertManyAsync
Inserts rows, several to a statement, all or none.
Task<int> InsertManyAsync(
IDbConnection db,
Type type,
Object} rows,
IDbTransaction tx,
CancellationToken cancellationToken)Parameters
- db (IDbConnection) - The connection.
- type (Type) - The model type.
- rows (Object}) - The rows.
- tx (IDbTransaction) - The transaction to use, or null.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<int>
The number of rows inserted.
UpdateAsync
Updates every column of a row but its key, by its key.
Task<int> UpdateAsync(
IDbConnection db,
Type type,
object row,
IDbTransaction tx,
CancellationToken cancellationToken)Parameters
- db (IDbConnection) - The connection.
- type (Type) - The model type.
- row (object) - The row.
- tx (IDbTransaction) - The transaction to use, or null.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<int>
The number of rows updated: 1, or 0 if no row has the key.
DeleteAsync
Deletes a row, by its key.
Task<int> DeleteAsync(
IDbConnection db,
Type type,
object row,
IDbTransaction tx,
CancellationToken cancellationToken)Parameters
- db (IDbConnection) - The connection.
- type (Type) - The model type.
- row (object) - The row.
- tx (IDbTransaction) - The transaction to use, or null.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<int>
The number of rows deleted: 1, or 0 if no row has the key.
DeleteByIdAsync
Deletes the row with a key.
Task<int> DeleteByIdAsync(
IDbConnection db,
Type type,
object key,
IDbTransaction tx,
CancellationToken cancellationToken)Parameters
- db (IDbConnection) - The connection.
- type (Type) - The model type.
- key (object) - The key: its value, or for a composite key an object or tuple holding each key property.
- tx (IDbTransaction) - The transaction to use, or null.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<int>
The number of rows deleted: 1, or 0 if no row has the key.
SingleByIdAsync
Reads the row with a key.
Task<object?> SingleByIdAsync(
IDbConnection db,
Type type,
object key,
IDbTransaction tx,
CancellationToken cancellationToken)Parameters
- db (IDbConnection) - The connection.
- type (Type) - The model type.
- key (object) - The key: its value, or for a composite key an object or tuple holding each key property.
- tx (IDbTransaction) - The transaction to use, or null.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<object?>
The row, or null if there is none.
SelectByIdsAsync
Reads the rows with any of the given keys, in no particular order.
Task<List<object>> SelectByIdsAsync(
IDbConnection db,
Type type,
Object} keys,
IDbTransaction tx,
CancellationToken cancellationToken)Parameters
- db (IDbConnection) - The connection.
- type (Type) - The model type.
- keys (Object}) - The keys.
- tx (IDbTransaction) - The transaction to use, or null.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<List<object>>
The rows found.
SelectAsync
Reads every row of a model.
Task<List<object>> SelectAsync(
IDbConnection db,
Type type,
IDbTransaction tx,
CancellationToken cancellationToken)Parameters
- db (IDbConnection) - The connection.
- type (Type) - The model type.
- tx (IDbTransaction) - The transaction to use, or null.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<List<object>>
The rows, in no particular order.
FirstAsync
Reads the row of a model with the lowest key.
Task<object?> FirstAsync(
IDbConnection db,
Type type,
IDbTransaction tx,
CancellationToken cancellationToken)Parameters
- db (IDbConnection) - The connection.
- type (Type) - The model type.
- tx (IDbTransaction) - The transaction to use, or null.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<object?>
The row with the lowest key, any row for a model with no key, or null if there are none.
CountAsync
Counts the rows of a model.
Task<long> CountAsync(
IDbConnection db,
Type type,
IDbTransaction tx,
CancellationToken cancellationToken)Parameters
- db (IDbConnection) - The connection.
- type (Type) - The model type.
- tx (IDbTransaction) - The transaction to use, or null.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<long>
The number of rows.
ExistsAsync
Tells whether a model's table has any rows.
Task<bool> ExistsAsync(
IDbConnection db,
Type type,
IDbTransaction tx,
CancellationToken cancellationToken)Parameters
- db (IDbConnection) - The connection.
- type (Type) - The model type.
- tx (IDbTransaction) - The transaction to use, or null.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<bool>
True if it does.
DeleteAllAsync
Deletes every row.
Task<int> DeleteAllAsync(
IDbConnection db,
Type type,
IDbTransaction tx,
CancellationToken cancellationToken)Parameters
- db (IDbConnection) - The connection.
- type (Type) - The model type.
- tx (IDbTransaction) - The transaction to use, or null.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<int>
The number of rows deleted.
PatchAsync
Sets the columns a patch has values for, leaving the rest unchanged.
Task<int> PatchAsync(
IDbConnection db,
object patch,
Func{``0 where,
Boolean}} setNull,
Func{``0 tx,
Object}} cancellationToken)Parameters
db (IDbConnection) - The connection.
patch (object) - Any object whose properties are named as the model's are: a null property leaves its column unchanged, and a property the model has no column for is an error.
where (Func{``0) - The rows to patch; or null for the row with the key the patch holds.
setNull (Boolean}}) - .
tx (Func{``0) - The transaction to use, or null.
cancellationToken (Object}}) - The cancellation token.
Returns
Type: Task<int>
The number of rows patched; 0 without a round trip if the patch sets nothing.
PatchAsync
Sets the columns a patch has values for in the row with the key the patch holds, leaving the rest unchanged.
Task<int> PatchAsync(
IDbConnection db,
Type type,
object patch,
String} setNull,
IDbTransaction tx,
CancellationToken cancellationToken)Parameters
- db (IDbConnection) - The connection.
- type (Type) - The model type.
- patch (object) - Any object whose properties are named as the model's are.
- setNull (String}) - The names of the properties whose columns to set to NULL, or null.
- tx (IDbTransaction) - The transaction to use, or null.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<int>
The number of rows patched: 1, or 0 if no row has the key or the patch sets nothing.
UpsertAsync
Inserts a row, or updates every column of the row with its key if there is one.
Task<object?> UpsertAsync(
IDbConnection db,
``0 row,
IDbTransaction tx,
CancellationToken cancellationToken)Parameters
- db (IDbConnection) - The connection.
- row (``0) - The row.
- tx (IDbTransaction) - The transaction to use, or null.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<object?>
The row's key, as InsertAsync returns it.
UpsertAsync
Inserts a row, or updates every column of the row with its key if there is one.
Task<object?> UpsertAsync(
IDbConnection db,
Type type,
object row,
IDbTransaction tx,
CancellationToken cancellationToken)Parameters
- db (IDbConnection) - The connection.
- type (Type) - The model type.
- row (object) - The row.
- tx (IDbTransaction) - The transaction to use, or null.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<object?>
The row's key, as InsertAsync returns it.
UpsertAsync
Inserts a row, or updates the row it conflicts with as the options say.
Task<object?> UpsertAsync(
IDbConnection db,
``0 row,
DmUpsertOptions{``0} options,
IDbTransaction tx,
CancellationToken cancellationToken)Parameters
- db (IDbConnection) - The connection.
- row (``0) - The row.
- options (DmUpsertOptions{``0}) - The conflict columns, what to set, and when.
- tx (IDbTransaction) - The transaction to use, or null.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<object?>
The row's key: for a key the database generates, the inserted or conflicting row's, also set on the row.
InsertIfAbsentAsync
Inserts a row unless a row with its primary key exists.
Task<bool> InsertIfAbsentAsync(
IDbConnection db,
``0 row,
IDbTransaction tx,
CancellationToken cancellationToken)Parameters
- db (IDbConnection) - The connection.
- row (``0) - The row.
- tx (IDbTransaction) - The transaction to use, or null.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<bool>
True if the row was inserted; a key the database generated is then set on it.
InsertIfAbsentAsync
Inserts a row unless a row with the same values in some columns exists.
Task<bool> InsertIfAbsentAsync(
IDbConnection db,
``0 row,
Func{``0 onConflict,
Object}} tx,
IDbTransaction cancellationToken)Parameters
- db (IDbConnection) - The connection.
- row (``0) - The row.
- onConflict (Func{``0) - The columns: the primary key or the columns of a unique constraint or index.
- tx (Object}}) - The transaction to use, or null.
- cancellationToken (IDbTransaction) - The cancellation token.
Returns
Type: Task<bool>
True if the row was inserted; a key the database generated is then set on it.
InsertIfAbsentAsync
Inserts a row unless a row with its primary key exists.
Task<bool> InsertIfAbsentAsync(
IDbConnection db,
Type type,
object row,
IDbTransaction tx,
CancellationToken cancellationToken)Parameters
- db (IDbConnection) - The connection.
- type (Type) - The model type.
- row (object) - The row.
- tx (IDbTransaction) - The transaction to use, or null.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<bool>
True if the row was inserted; a key the database generated is then set on it.
BulkInsertAsync
Inserts rows in bulk, all or none, through the provider's native bulk path, or multi-row VALUES without one.
Task<long> BulkInsertAsync(
IDbConnection db,
IEnumerable{``0} rows,
IDbTransaction tx,
CancellationToken cancellationToken)Parameters
- db (IDbConnection) - The connection.
- rows (IEnumerable{``0}) - The rows, read once, as they are loaded.
- tx (IDbTransaction) - The transaction to use, or null for one of the method's own.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<long>
The number of rows inserted.
BulkInsertAsync
Inserts rows in bulk, all or none, with options.
Task<long> BulkInsertAsync(
IDbConnection db,
IEnumerable{``0} rows,
DmBulkOptions options,
IDbTransaction tx,
CancellationToken cancellationToken)Parameters
- db (IDbConnection) - The connection.
- rows (IEnumerable{``0}) - The rows, read once, as they are loaded.
- options (DmBulkOptions) - The batch size, the timeout, and what to do without a native path.
- tx (IDbTransaction) - The transaction to use, or null for one of the method's own.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<long>
The number of rows inserted.
BulkInsertAsync
Inserts rows of a model known at run time in bulk, all or none.
Task<long> BulkInsertAsync(
IDbConnection db,
Type type,
Object} rows,
IDbTransaction tx,
CancellationToken cancellationToken)Parameters
- db (IDbConnection) - The connection.
- type (Type) - The model type.
- rows (Object}) - The rows, read once, as they are loaded.
- tx (IDbTransaction) - The transaction to use, or null for one of the method's own.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<long>
The number of rows inserted.
BulkInsertAsync
Inserts rows of a model known at run time in bulk, all or none, with options.
Task<long> BulkInsertAsync(
IDbConnection db,
Type type,
Object} rows,
DmBulkOptions options,
IDbTransaction tx,
CancellationToken cancellationToken)Parameters
- db (IDbConnection) - The connection.
- type (Type) - The model type.
- rows (Object}) - The rows, read once, as they are loaded.
- options (DmBulkOptions) - The batch size, the timeout, and what to do without a native path.
- tx (IDbTransaction) - The transaction to use, or null for one of the method's own.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<long>
The number of rows inserted.
BulkUpsertAsync
Inserts rows in bulk, or updates the rows with their primary keys, all or none, through a staging table.
Task<long> BulkUpsertAsync(
IDbConnection db,
IEnumerable{``0} rows,
IDbTransaction tx,
CancellationToken cancellationToken)Parameters
- db (IDbConnection) - The connection.
- rows (IEnumerable{``0}) - The rows, read once; no two may have the same key.
- tx (IDbTransaction) - The transaction to use, or null for one of the method's own.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<long>
The number of rows loaded.
BulkUpsertAsync
Inserts rows in bulk, or updates the rows they conflict with as the options say, all or none.
Task<long> BulkUpsertAsync(
IDbConnection db,
IEnumerable{``0} rows,
DmUpsertOptions{``0} upsert,
DmBulkOptions bulk,
IDbTransaction tx,
CancellationToken cancellationToken)Parameters
- db (IDbConnection) - The connection.
- rows (IEnumerable{``0}) - The rows, read once; no two may conflict with each other.
- upsert (DmUpsertOptions{``0}) - The conflict columns, what to set, and when.
- bulk (DmBulkOptions) - The batch size, the timeout, and what to do without a native path; null for the defaults.
- tx (IDbTransaction) - The transaction to use, or null for one of the method's own.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<long>
The number of rows loaded.
BulkUpsertAsync
Inserts rows of a model known at run time in bulk, or updates the rows with their primary keys, all or none.
Task<long> BulkUpsertAsync(
IDbConnection db,
Type type,
Object} rows,
IDbTransaction tx,
CancellationToken cancellationToken)Parameters
- db (IDbConnection) - The connection.
- type (Type) - The model type.
- rows (Object}) - The rows, read once; no two may have the same key.
- tx (IDbTransaction) - The transaction to use, or null for one of the method's own.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<long>
The number of rows loaded.
LoadAsync
Loads relations onto rows already read, by one query per relation and batch of the rows' keys.
Task LoadAsync(
IDbConnection db,
IEnumerable{``0} rows,
DmInclude{``0} include,
DmInclude{``0}} reload,
bool tx,
IDbTransaction cancellationToken)Parameters
- db (IDbConnection) - The connection.
- rows (IEnumerable{``0}) - The rows.
- include (DmInclude{``0}) - .
- reload (DmInclude{``0}}) - Whether to load a relation onto a row that has it already.
- tx (bool) - The transaction to use, or null.
- cancellationToken (IDbTransaction) - The cancellation token.
Returns
Type: Task
A task.
ForTenant
Reads and writes only a tenant's rows of models with a <c>[DmTenantKey]</c>, and sets it on rows inserted.
DmScope ForTenant(IDbConnection db, object tenantId)Parameters
- db (IDbConnection) - The connection.
- tenantId (object) - The tenant's id.
Returns
Type: DmScope
A scope for the tenant, with the same methods as the connection.
AllTenants
Reads and writes every tenant's rows of models with a <c>[DmTenantKey]</c>.
DmScope AllTenants(IDbConnection db)Parameters
- db (IDbConnection) - The connection.
Returns
Type: DmScope
A scope for every tenant.
WithUser
Sets the user <c>[DmCreatedBy]</c> and <c>[DmUpdatedBy]</c> record.
DmScope WithUser(IDbConnection db, object user)Parameters
- db (IDbConnection) - The connection.
- user (object) - The user, or null for none.
Returns
Type: DmScope
A scope for the user.
IncludeDeleted
Reads deleted rows of models with a <c>[DmSoftDelete]</c> too.
DmScope IncludeDeleted(IDbConnection db)Parameters
- db (IDbConnection) - The connection.
Returns
Type: DmScope
A scope that sees deleted rows.
OnlyDeleted
Reads only the deleted rows of the models a statement reads.
DmScope OnlyDeleted(IDbConnection db)Parameters
- db (IDbConnection) - The connection.
Returns
Type: DmScope
A scope that sees only deleted rows.
HardDeleteAsync
Removes a row by its key, even of a model with a <c>[DmSoftDelete]</c>.
Task<int> HardDeleteAsync(
IDbConnection db,
``0 row,
IDbTransaction tx,
CancellationToken cancellationToken)Parameters
- db (IDbConnection) - The connection.
- row (``0) - The row.
- tx (IDbTransaction) - The transaction to use, or null.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<int>
The number of rows removed.
HardDeleteAsync
Removes a row of a model known at run time by its key, even of a model with a <c>[DmSoftDelete]</c>.
Task<int> HardDeleteAsync(
IDbConnection db,
Type type,
object row,
IDbTransaction tx,
CancellationToken cancellationToken)Parameters
- db (IDbConnection) - The connection.
- type (Type) - The model type.
- row (object) - The row.
- tx (IDbTransaction) - The transaction to use, or null.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<int>
The number of rows removed.
HardDeleteByIdAsync
Removes the row with a key, even of a model with a <c>[DmSoftDelete]</c>.
Task<int> HardDeleteByIdAsync(
IDbConnection db,
object key,
IDbTransaction tx,
CancellationToken cancellationToken)Parameters
- db (IDbConnection) - The connection.
- key (object) - takes it.
- tx (IDbTransaction) - The transaction to use, or null.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<int>
The number of rows removed.
HardDeleteByIdAsync
Removes the row of a model known at run time with a key, even of a model with a <c>[DmSoftDelete]</c>.
Task<int> HardDeleteByIdAsync(
IDbConnection db,
Type type,
object key,
IDbTransaction tx,
CancellationToken cancellationToken)Parameters
- db (IDbConnection) - The connection.
- type (Type) - The model type.
- key (object) - The key.
- tx (IDbTransaction) - The transaction to use, or null.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<int>
The number of rows removed.
HardDeleteAsync
Removes the rows that match a condition, deleted or not.
Task<int> HardDeleteAsync(
IDbConnection db,
Func{``0 where,
Boolean}} tx,
IDbTransaction cancellationToken)Parameters
- db (IDbConnection) - The connection.
- where (Func{``0) - The condition.
- tx (Boolean}}) - The transaction to use, or null.
- cancellationToken (IDbTransaction) - The cancellation token.
Returns
Type: Task<int>
The number of rows removed.
HardDeleteAllAsync
Removes every row, deleted or not.
Task<int> HardDeleteAllAsync(
IDbConnection db,
IDbTransaction tx,
CancellationToken cancellationToken)Parameters
- db (IDbConnection) - The connection.
- tx (IDbTransaction) - The transaction to use, or null.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<int>
The number of rows removed.
HardDeleteAllAsync
Removes every row of a model known at run time, deleted or not.
Task<int> HardDeleteAllAsync(
IDbConnection db,
Type type,
IDbTransaction tx,
CancellationToken cancellationToken)Parameters
- db (IDbConnection) - The connection.
- type (Type) - The model type.
- tx (IDbTransaction) - The transaction to use, or null.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<int>
The number of rows removed.
GetType
GetType()ToString
ToString()Equals
Equals()GetHashCode
GetHashCode()