-
Notifications
You must be signed in to change notification settings - Fork 220
/
Copy pathGetItem.cs
38 lines (34 loc) · 1.09 KB
/
GetItem.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
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Amazon;
using Amazon.DynamoDBv2;
using Amazon.DynamoDBv2.Model;
namespace DotnetSamples.WorkingWithItems
{
class GetItem
{
public static async Task ServiceClientExampleAsync()
{
try
{
var client = new AmazonDynamoDBClient(RegionEndpoint.USWest2);
var request = new GetItemRequest
{
TableName = "RetailDatabase",
Key = new Dictionary<string, AttributeValue>
{
{"pk", new AttributeValue {S = "[email protected]"} },
{"sk", new AttributeValue {S = "metadata"} }
}
};
var response = await client.GetItemAsync(request);
Console.WriteLine($"Item retrieved with {response.Item.Count} attributes.");
}
catch(Exception e)
{
Console.Error.WriteLine(e.Message);
}
}
}
}