Let's understand how to delete an item from the DynamoDB table using the AWS SDK for .Net.
Let's try to understand how to delete a stored item from the DynamoDB table using .Net:
Create an instance of the
DynamoDBClient
class:AmazonDynamoDBClient client = new AmazonDynamoDBClient(); string tableName = "productTable";
Create a
delete
table request and specify the key of the item that you wish to delete from the table. Here, we will specify both thehash
andrange
keys, as we have created a table with the compositeprimary
keys:var request = new DeleteItemRequest { TableName = tableName, Key = new Dictionary<string,AttributeValue>() { { "id", new AttributeValue { N = "20" } }, { "type", new AttributeValue { S = "phone" }} } };
Invoke the
DeleteItem
method specifying the request:var response = client.DeleteItem(request);