Exclua uma única linha de uma tabela do Tablestore com o .NET SDK.
Pré-requisitos
Método
public DeleteRowResponse DeleteRow(DeleteRowRequest request)
Método assíncrono:
public Task<DeleteRowResponse> DeleteRowAsync(DeleteRowRequest request)
Código de exemplo
O exemplo a seguir exclui a linha com valor de chave primária "row1" da tabela test_table.
try
{
// Construct the primary key.
PrimaryKey primaryKey = new PrimaryKey
{
{ "id", new ColumnValue("row1") }
};
// A condition is required to delete a row. RowExistenceExpectation.IGNORE indicates that the operation proceeds without checking if the row exists.
Condition condition = new Condition(RowExistenceExpectation.IGNORE);
// Send the request to delete the row.
DeleteRowRequest deleteRowRequest = new DeleteRowRequest("test_table", condition, primaryKey);
DeleteRowResponse deleteRowResponse = client.DeleteRow(deleteRowRequest);
Console.WriteLine($"RequestId: {deleteRowResponse.RequestID}");
Console.WriteLine($"Read CU Cost: {deleteRowResponse.ConsumedCapacityUnit.Read}");
Console.WriteLine($"Write CU Cost: {deleteRowResponse.ConsumedCapacityUnit.Write}");
}
catch (Exception ex)
{
Console.WriteLine($"Delete row failed, exception: {ex.Message}");
}