-
Notifications
You must be signed in to change notification settings - Fork 228
/
Copy pathQueryCount.cs
38 lines (35 loc) · 1.22 KB
/
QueryCount.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.WorkingWithQueries
{
public class QueryCount
{
public static async Task CountDbClientExampleAsync()
{
try
{
var client = new AmazonDynamoDBClient(RegionEndpoint.USEast1);
var request = new QueryRequest
{
TableName="MyTableName",
KeyConditionExpression="PK = :pk AND begins_with(SK, :sk)",
ExpressionAttributeValues = new Dictionary<string, AttributeValue>
{
{ ":pk", new AttributeValue { S="Customer1" } },
{ ":sk", new AttributeValue { S="ORDER|"} }
}
};
var response = await client.QueryAsync(request);
Console.WriteLine($"The query has scanned {response.ScannedCount} items and returned ${response.Count} items in total");
}
catch(Exception ex)
{
Console.Error.WriteLine(ex.Message);
}
}
}
}