Skip to content

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 ​

MethodSummary
AsCallerAsyncRuns statements on the connection as a caller, held to the policies as the web API holds requests: s...
InSchemaUses a schema for every model, such as a tenant's, instead of each model's own.
WithTableNameUses a table for a model, such as an archive table, instead of the model's own.
FromStarts a query of a model's rows, refined with <c>Where</c>, <c>OrderBy</c>,...
InsertAsyncInserts a row.
InsertManyAsyncInserts rows, several to a statement, all or none.
UpdateAsyncUpdates every column of a row but its key, by its key.
DeleteAsyncDeletes a row, by its key.
DeleteByIdAsyncDeletes the row with a key.
SingleByIdAsyncReads the row with a key.
SelectByIdsAsyncReads the rows with any of the given keys, in no particular order.
SelectAsyncReads the rows that match a condition, or every row.
SingleAsyncReads the one row that matches a condition.
FirstAsyncReads the first row that matches a condition, in key order.
CountAsyncCounts the rows that match a condition, or every row.
ExistsAsyncTells whether any row matches a condition, or whether the table has any rows.
UpdateAsyncSets columns of the rows that match a condition.
DeleteAsyncDeletes the rows that match a condition.
DeleteAllAsyncDeletes every row.
WithTableNameUses a table for a model, such as an archive table, instead of the model's own.
InsertAsyncInserts a row.
InsertManyAsyncInserts rows, several to a statement, all or none.
UpdateAsyncUpdates every column of a row but its key, by its key.
DeleteAsyncDeletes a row, by its key.
DeleteByIdAsyncDeletes the row with a key.
SingleByIdAsyncReads the row with a key.
SelectByIdsAsyncReads the rows with any of the given keys, in no particular order.
SelectAsyncReads every row of a model.
FirstAsyncReads the row of a model with the lowest key.
CountAsyncCounts the rows of a model.
ExistsAsyncTells whether a model's table has any rows.
DeleteAllAsyncDeletes every row.
PatchAsyncSets the columns a patch has values for, leaving the rest unchanged.
PatchAsyncSets the columns a patch has values for in the row with the key the patch holds, leaving the rest un...
UpsertAsyncInserts a row, or updates every column of the row with its key if there is one.
UpsertAsyncInserts a row, or updates every column of the row with its key if there is one.
UpsertAsyncInserts a row, or updates the row it conflicts with as the options say.
InsertIfAbsentAsyncInserts a row unless a row with its primary key exists.
InsertIfAbsentAsyncInserts a row unless a row with the same values in some columns exists.
InsertIfAbsentAsyncInserts a row unless a row with its primary key exists.
BulkInsertAsyncInserts rows in bulk, all or none, through the provider's native bulk path, or multi-row VALUES with...
BulkInsertAsyncInserts rows in bulk, all or none, with options.
BulkInsertAsyncInserts rows of a model known at run time in bulk, all or none.
BulkInsertAsyncInserts rows of a model known at run time in bulk, all or none, with options.
BulkUpsertAsyncInserts rows in bulk, or updates the rows with their primary keys, all or none, through a staging ta...
BulkUpsertAsyncInserts rows in bulk, or updates the rows they conflict with as the options say, all or none.
BulkUpsertAsyncInserts rows of a model known at run time in bulk, or updates the rows with their primary keys, all ...
LoadAsyncLoads relations onto rows already read, by one query per relation and batch of the rows' keys.
ForTenantReads and writes only a tenant's rows of models with a <c>[DmTenantKey]</c>, and sets it...
AllTenantsReads and writes every tenant's rows of models with a <c>[DmTenantKey]</c>.
WithUserSets the user <c>[DmCreatedBy]</c> and <c>[DmUpdatedBy]</c> record.
IncludeDeletedReads deleted rows of models with a <c>[DmSoftDelete]</c> too.
OnlyDeletedReads only the deleted rows of the models a statement reads.
HardDeleteAsyncRemoves a row by its key, even of a model with a <c>[DmSoftDelete]</c>.
HardDeleteAsyncRemoves a row of a model known at run time by its key, even of a model with a <c>[DmSoftDelete
HardDeleteByIdAsyncRemoves the row with a key, even of a model with a <c>[DmSoftDelete]</c>.
HardDeleteByIdAsyncRemoves the row of a model known at run time with a key, even of a model with a <c>[DmSoftDele...
HardDeleteAsyncRemoves the rows that match a condition, deleted or not.
HardDeleteAllAsyncRemoves every row, deleted or not.
HardDeleteAllAsyncRemoves 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).

csharp
Task&lt;DmScope&gt; 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.

csharp
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.

csharp
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>.

csharp
DmQuery&lt;T&gt; 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.

csharp
Task&lt;object?&gt; 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&lt;object?&gt;

        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.

csharp
Task&lt;int&gt; 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&lt;int&gt;

The number of rows inserted.

UpdateAsync ​

Updates every column of a row but its key, by its key.

csharp
Task&lt;int&gt; 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&lt;int&gt;

The number of rows updated: 1, or 0 if no row has the key.

DeleteAsync ​

Deletes a row, by its key.

csharp
Task&lt;int&gt; 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&lt;int&gt;

The number of rows deleted: 1, or 0 if no row has the key.

DeleteByIdAsync ​

Deletes the row with a key.

csharp
Task&lt;int&gt; 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&lt;int&gt;

The number of rows deleted: 1, or 0 if no row has the key.

SingleByIdAsync ​

Reads the row with a key.

csharp
Task&lt;T?&gt; 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&lt;T?&gt;

The row, or null if there is none.

SelectByIdsAsync ​

Reads the rows with any of the given keys, in no particular order.

csharp
Task&lt;List&lt;T&gt;&gt; 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&lt;List&lt;T&gt;&gt;

The rows found.

SelectAsync ​

Reads the rows that match a condition, or every row.

csharp
Task&lt;List&lt;T&gt;&gt; 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&lt;List&lt;T&gt;&gt;

The rows, in no particular order.

SingleAsync ​

Reads the one row that matches a condition.

csharp
Task&lt;T?&gt; 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&lt;T?&gt;

The row, or null if no row matches.

FirstAsync ​

Reads the first row that matches a condition, in key order.

csharp
Task&lt;T?&gt; 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&lt;T?&gt;

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.

csharp
Task&lt;long&gt; 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&lt;long&gt;

The number of rows.

ExistsAsync ​

Tells whether any row matches a condition, or whether the table has any rows.

csharp
Task&lt;bool&gt; 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&lt;bool&gt;

True if a row matches.

UpdateAsync ​

Sets columns of the rows that match a condition.

csharp
Task&lt;int&gt; 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&lt;int&gt;

The number of rows updated.

DeleteAsync ​

Deletes the rows that match a condition.

csharp
Task&lt;int&gt; 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&lt;int&gt;

The number of rows deleted.

DeleteAllAsync ​

Deletes every row.

csharp
Task&lt;int&gt; 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&lt;int&gt;

The number of rows deleted.

WithTableName ​

Uses a table for a model, such as an archive table, instead of the model's own.

csharp
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.

csharp
Task&lt;object?&gt; 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&lt;object?&gt;

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.

csharp
Task&lt;int&gt; 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&lt;int&gt;

The number of rows inserted.

UpdateAsync ​

Updates every column of a row but its key, by its key.

csharp
Task&lt;int&gt; 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&lt;int&gt;

The number of rows updated: 1, or 0 if no row has the key.

DeleteAsync ​

Deletes a row, by its key.

csharp
Task&lt;int&gt; 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&lt;int&gt;

The number of rows deleted: 1, or 0 if no row has the key.

DeleteByIdAsync ​

Deletes the row with a key.

csharp
Task&lt;int&gt; 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&lt;int&gt;

The number of rows deleted: 1, or 0 if no row has the key.

SingleByIdAsync ​

Reads the row with a key.

csharp
Task&lt;object?&gt; 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&lt;object?&gt;

The row, or null if there is none.

SelectByIdsAsync ​

Reads the rows with any of the given keys, in no particular order.

csharp
Task&lt;List&lt;object&gt;&gt; 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&lt;List&lt;object&gt;&gt;

The rows found.

SelectAsync ​

Reads every row of a model.

csharp
Task&lt;List&lt;object&gt;&gt; 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&lt;List&lt;object&gt;&gt;

The rows, in no particular order.

FirstAsync ​

Reads the row of a model with the lowest key.

csharp
Task&lt;object?&gt; 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&lt;object?&gt;

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.

csharp
Task&lt;long&gt; 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&lt;long&gt;

The number of rows.

ExistsAsync ​

Tells whether a model's table has any rows.

csharp
Task&lt;bool&gt; 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&lt;bool&gt;

True if it does.

DeleteAllAsync ​

Deletes every row.

csharp
Task&lt;int&gt; 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&lt;int&gt;

The number of rows deleted.

PatchAsync ​

Sets the columns a patch has values for, leaving the rest unchanged.

csharp
Task&lt;int&gt; 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&lt;int&gt;

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.

csharp
Task&lt;int&gt; 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&lt;int&gt;

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.

csharp
Task&lt;object?&gt; 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&lt;object?&gt;

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.

csharp
Task&lt;object?&gt; 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&lt;object?&gt;

The row's key, as InsertAsync returns it.

UpsertAsync ​

Inserts a row, or updates the row it conflicts with as the options say.

csharp
Task&lt;object?&gt; 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&lt;object?&gt;

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.

csharp
Task&lt;bool&gt; 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&lt;bool&gt;

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.

csharp
Task&lt;bool&gt; 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&lt;bool&gt;

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.

csharp
Task&lt;bool&gt; 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&lt;bool&gt;

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.

csharp
Task&lt;long&gt; 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&lt;long&gt;

The number of rows inserted.

BulkInsertAsync ​

Inserts rows in bulk, all or none, with options.

csharp
Task&lt;long&gt; 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&lt;long&gt;

The number of rows inserted.

BulkInsertAsync ​

Inserts rows of a model known at run time in bulk, all or none.

csharp
Task&lt;long&gt; 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&lt;long&gt;

The number of rows inserted.

BulkInsertAsync ​

Inserts rows of a model known at run time in bulk, all or none, with options.

csharp
Task&lt;long&gt; 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&lt;long&gt;

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.

csharp
Task&lt;long&gt; 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&lt;long&gt;

The number of rows loaded.

BulkUpsertAsync ​

Inserts rows in bulk, or updates the rows they conflict with as the options say, all or none.

csharp
Task&lt;long&gt; 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&lt;long&gt;

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.

csharp
Task&lt;long&gt; 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&lt;long&gt;

The number of rows loaded.

LoadAsync ​

Loads relations onto rows already read, by one query per relation and batch of the rows' keys.

csharp
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.

csharp
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>.

csharp
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.

csharp
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.

csharp
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.

csharp
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>.

csharp
Task&lt;int&gt; 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&lt;int&gt;

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>.

csharp
Task&lt;int&gt; 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&lt;int&gt;

The number of rows removed.

HardDeleteByIdAsync ​

Removes the row with a key, even of a model with a <c>[DmSoftDelete]</c>.

csharp
Task&lt;int&gt; 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&lt;int&gt;

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>.

csharp
Task&lt;int&gt; 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&lt;int&gt;

The number of rows removed.

HardDeleteAsync ​

Removes the rows that match a condition, deleted or not.

csharp
Task&lt;int&gt; 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&lt;int&gt;

The number of rows removed.

HardDeleteAllAsync ​

Removes every row, deleted or not.

csharp
Task&lt;int&gt; 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&lt;int&gt;

The number of rows removed.

HardDeleteAllAsync ​

Removes every row of a model known at run time, deleted or not.

csharp
Task&lt;int&gt; 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&lt;int&gt;

The number of rows removed.

GetType ​

csharp
GetType()

ToString ​

csharp
ToString()

Equals ​

csharp
Equals()

GetHashCode ​

csharp
GetHashCode()