Method DeleteManyAsync
DeleteManyAsync(String, IReadOnlyCollection<MapValue>, DeleteManyOptions, CancellationToken)
Atomically executes a sequence of Delete operations on a table.
Declaration
public Task<WriteManyResult<RecordValue>> DeleteManyAsync(string tableName, IReadOnlyCollection<MapValue> primaryKeys, DeleteManyOptions options = null, CancellationToken cancellationToken = null)
Parameters
| Type | Name | Description |
|---|---|---|
| String | tableName | The name of the table. |
| IReadOnlyCollection<MapValue> | primaryKeys | A collection of primary keys that identify the rows to delete in a single transaction (can be an array, list or any other class implementing IReadOnlyCollection<T>) |
| DeleteManyOptions | options | (Optional) Options for the DeleteMany
operation. If not specified or null, appropriate defaults
will be used. See DeleteManyOptions. |
| CancellationToken | cancellationToken | (Optional) Cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<WriteManyResult<RecordValue>> | Task returning WriteManyResult<TRow>. |
Remarks
This API is a shorthand for
WriteManyAsync(String, WriteOperationCollection, WriteManyOptions, CancellationToken)
and can be used instead of it when all of the following is true:
- All operations are on a single table.
- All operations in the sequence are Delete (no Put operations).
- You don't need to specify separate DeleteOptions for each operation in the sequence and instead it is sufficient to specify the same options for all operations in DeleteManyOptions.
- There are no Delete operations in the sequence conditional on RowVersion (because the version has to be specified individually for each row).
Examples
Performing DeleteMany operation.var primaryKey1 = new MapValue
{
["id"] = 1000
};
var primaryKey2 = new MapValue
{
["id"] = 1001
};
var primaryKey3 = new MapValue
{
["id"]= 1002
};
var result = await client.DeleteManyAsync(
"myTable",
new[] { primaryKey1, primaryKey2, primaryKey3 });
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | If
tableName is null or invalid or
primaryKeys is null or contains invalid
values or options contains invalid values.
|
| TimeoutException | Operation has timed out. |
| InvalidOperationException | The table or the service is not in a valid state to perform this operation. |
| NoSQLException | NoSQLException or one of its subclasses is thrown if operation cannot be performed for any other reason. See documentation for corresponding subclass of NoSQLException. |