.NET SDK kullanarak Tablestore tablosundan tek bir satır silin.
Ön koşullar
Yöntem
public DeleteRowResponse DeleteRow(DeleteRowRequest request)
Eşzamansız yöntem:
public Task<DeleteRowResponse> DeleteRowAsync(DeleteRowRequest request)
Örnek kod
Aşağıdaki örnek, test_table tablosundan birincil anahtar değeri "row1" olan satırı siler.
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}");
}