-
Notifications
You must be signed in to change notification settings - Fork 228
/
Copy pathQueryProjectionExpression.cs
42 lines (39 loc) · 1.28 KB
/
QueryProjectionExpression.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
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Amazon;
using Amazon.DynamoDBv2;
using Amazon.DynamoDBv2.Model;
namespace DotnetSamples.WorkingWithQueries
{
public class QueryProjectionExpression
{
public async Task QueryProjectionExpressionDbClientExmaple()
{
try
{
var client = new AmazonDynamoDBClient(RegionEndpoint.USEast1);
var request = new QueryRequest
{
TableName="MyTableName",
ProjectionExpression="CustomerId, #cn",
ExpressionAttributeNames= new Dictionary<string, string>
{
{ "#cn", "CustomerName" }
},
KeyConditionExpression="PK = :pk",
ExpressionAttributeValues = new Dictionary<string, AttributeValue>
{
{ ":pk", new AttributeValue { S="Customer1" } },
},
};
var response = await client.QueryAsync(request);
Console.WriteLine("Success");
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
}