public async Task <List <Dictionary <string, AttributeValue> > > QueryByDomain(string domain, int limit, bool asc, Dictionary <string, AttributeValue> lastEvaluatedKey = null) { var queryRequest = new QueryRequest() { TableName = TableName, IndexName = "gidx_Domain", Limit = limit, ScanIndexForward = asc, ProjectionExpression = "MessageId, CreatedTimeStampUtc, PublishedTimeStampUtc, Domain, MessageType", KeyConditionExpression = "Domain = :domain", ReturnConsumedCapacity = new ReturnConsumedCapacity("INDEXES"), ExpressionAttributeValues = new Dictionary <string, AttributeValue>() { { ":domain", new AttributeValue() { S = domain } } } }; if (lastEvaluatedKey != null) { queryRequest.ExclusiveStartKey = lastEvaluatedKey; } var dynamodbClient = CreateDynamoDbClient(); var queryResponse = await dynamodbClient.QueryAsync(queryRequest); List <Dictionary <string, AttributeValue> > results = new AutoConstructedList <Dictionary <string, AttributeValue> >(); if (queryResponse.Items.Any() && queryResponse.Items.Count < limit && queryResponse.LastEvaluatedKey != null && queryResponse.LastEvaluatedKey.Any()) { var moreResults = await QueryByDomain(domain, limit - queryResponse.Items.Count, asc, queryResponse.LastEvaluatedKey); results.AddRange(moreResults); } else { results.AddRange(queryResponse.Items); } return(results); }
public void Set(Dictionary <string, string> values, string domainName, string itemName) { var client = new AmazonSimpleDBClient( new BasicAWSCredentials( this.AccessKey, this.SecretKey), this.RegionEndpoint); var unused1 = client.CreateDomainAsync( new CreateDomainRequest( domainName)).Result; var list = new AutoConstructedList <ReplaceableAttribute>(); list.AddRange( values.Select(i => new ReplaceableAttribute(i.Key, i.Value, true))); var unused2 = client.PutAttributesAsync( new PutAttributesRequest( domainName, itemName, list)).Result; }