Method PutManyAsync
PutManyAsync(String, IReadOnlyCollection<MapValue>, PutManyOptions, CancellationToken)
Atomically executes a sequence of Put operations on a table.
Declaration
public Task<WriteManyResult<RecordValue>> PutManyAsync(string tableName, IReadOnlyCollection<MapValue> rows, PutManyOptions options = null, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
String | tableName | The name of the table. |
IReadOnlyCollection<MapValue> | rows | A collection of rows to put in a single transaction (can be an array, list or any other class implementing IReadOnlyCollection<T>) |
PutManyOptions | options | (Optional) Options for the PutMany
operation. If not specified or null , appropriate defaults
will be used. See PutManyOptions. |
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 Put (no Delete operations).
- You don't need to specify separate PutOptions for each operation in the sequence and instead it is sufficient to specify the same options for all operations in PutManyOptions.
- There are no Put operations in the sequence conditional on RowVersion (because the version has to be specified individually for each row).
Examples
Performing PutMany operation.var row1 = new MapValue
{
["id"] = 1000,
["name"] = "John"
};
var row2 = new MapValue
{
["id"] = 1001,
["name"] = "Jane"
};
var row3 = new MapValue
{
["id"]= 1002,
["name"] = "Jill"
};
var result = await client.PutManyAsync(
"myTable",
new[] { row1, row2, row3 });
Exceptions
Type | Condition |
---|---|
ArgumentException | If
tableName is null or invalid or
rows 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. |