-
Notifications
You must be signed in to change notification settings - Fork 228
/
Copy pathDeleteItem.cs
49 lines (43 loc) · 1.32 KB
/
DeleteItem.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Amazon;
using Amazon.DynamoDBv2;
using Amazon.DynamoDBv2.Model;
namespace DotnetSamples.WorkingWithItems
{
public class DeleteItem
{
private readonly IAmazonDynamoDB amazonDynamoDB;
public DeleteItem()
{
amazonDynamoDB = new AmazonDynamoDBClient(RegionEndpoint.USWest2);
}
public DeleteItem(IAmazonDynamoDB amazonDynamoDB)
{
this.amazonDynamoDB = amazonDynamoDB;
}
public async Task ServiceClientExampleAsync()
{
try
{
var request = new DeleteItemRequest
{
TableName = "RetailDatabase",
Key = new Dictionary<string, AttributeValue>
{
{"pk", new AttributeValue {S = "[email protected]"} },
{"sk", new AttributeValue {S = "metadata"} }
}
};
var response = await amazonDynamoDB.DeleteItemAsync(request);
Console.WriteLine($"DeleteItem succeeded.");
}
catch (Exception e)
{
Console.Error.WriteLine(e.Message);
throw;
}
}
}
}