Method GetAsync
GetAsync(String, MapValue, GetOptions, CancellationToken)
Gets the row associated with a primary key.
Declaration
public Task<GetResult<RecordValue>> GetAsync(string tableName, MapValue primaryKey, GetOptions options = null, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
String | tableName | Name of the table. |
MapValue | primaryKey | Primary key of the row as MapValue representing names and values of the primary key fields. |
GetOptions | options | (Optional) Options for the Get operation.
If not specified or null , appropriate defaults will be
used. See GetOptions. |
CancellationToken | cancellationToken | (Optional) Cancellation token. |
Returns
Type | Description |
---|---|
Task<GetResult<RecordValue>> | Task returning GetResult<TRow> of
RecordValue. If there is no matching row,
Row is null . |
Remarks
On success the value of the row is available as
Row property. If matching row
does not exist, the operation is still successful and
Row property will be set to
null
.
Examples
Executing Get operation on table with schema MyTable(id LONG, name STRING, PRIMARY KEY(id)).var result = await client.GetAsync(
"MyTable",
new MapValue
{
["id"] = 1000
});
if (result.Row != null)
{
// result.Row.ToString() will produce JSON string:
// { id: 1000, name: "John" }
Console.WriteLine(result.Row);
}
Exceptions
Type | Condition |
---|---|
ArgumentException | If
tableName is null or invalid or
primaryKey is null or invalid or
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. |
See Also
GetResult<TRow>