public void DynamoDBBatchGetItem() { #region batch-get-item-1435614252853 var response = client.BatchGetItem(new BatchGetItemRequest { RequestItems = new Dictionary <string, KeysAndAttributes> { { "tablename1", new KeysAndAttributes { Keys = new List <Dictionary <string, AttributeValue> > { new Dictionary <string, AttributeValue> { { "key1", new AttributeValue { N = "NumberAttributeValue" } } } }, AttributesToGet = new List <string> { "attr1", "attr2" }, ConsistentRead = true, ProjectionExpression = "str1", ExpressionAttributeNames = new Dictionary <string, string> { { "name1", "attr3" }, { "name2", "attr4" } } } }, { "tablename2", new KeysAndAttributes { Keys = new List <Dictionary <string, AttributeValue> > { new Dictionary <string, AttributeValue> { { "key2", new AttributeValue { BOOL = true } } } }, AttributesToGet = new List <string> { "attr1", "attr2" }, ConsistentRead = false, ProjectionExpression = "str2", ExpressionAttributeNames = new Dictionary <string, string> { { "name1", "attr3" }, { "name2", "attr4" } } } } }, ReturnConsumedCapacity = "NONE" }); Dictionary <string, List <Dictionary <string, AttributeValue> > > responses = response.Responses; List <ConsumedCapacity> consumedCapacity = response.ConsumedCapacity; #endregion }
private static void CallUntilCompletion(IAmazonDynamoDB client, BatchGetItemRequest request, Results allResults) #endif { do { var serviceResponse = client.BatchGetItem(request); foreach (var kvp in serviceResponse.Responses) { var tableName = kvp.Key; var items = kvp.Value; allResults.Add(tableName, items); } request.RequestItems = serviceResponse.UnprocessedKeys; } while (request.RequestItems.Count > 0); }
IEnumerable <BatchGetItemResponse> IPaginator <BatchGetItemResponse> .Paginate() { if (Interlocked.Exchange(ref _isPaginatorInUse, 1) != 0) { throw new System.InvalidOperationException("Paginator has already been consumed and cannot be reused. Please create a new instance."); } var requestItems = _request.RequestItems; BatchGetItemResponse response; do { _request.RequestItems = requestItems; response = _client.BatchGetItem(_request); requestItems = response.UnprocessedKeys; yield return(response); }while (requestItems.Count > 0); }
private void CallUntilCompletion(IAmazonDynamoDB client, BatchGetItemRequest request) #endif { do { var result = client.BatchGetItem(request); var responses = result.Responses; foreach (var response in responses) { var tableName = response.Key; var items = response.Value; List <Dictionary <string, AttributeValue> > fetchedItems; if (!AllRetrievedItems.TryGetValue(tableName, out fetchedItems)) { fetchedItems = new List <Dictionary <string, AttributeValue> >(); AllRetrievedItems[tableName] = fetchedItems; } fetchedItems.AddRange(items); } request.RequestItems = result.UnprocessedKeys; } while (request.RequestItems.Count > 0); }