// TODO IAsyncEnumerable public IEnumerable <T> Enumerate(params Expression[] conditions) // Scans the entire table { // Each scan may return upto 1MB of data DynamoExpression?filterExpression = null; if (conditions.Length > 0) { filterExpression = DynamoExpression.Conjunction(conditions); } QueryResult?result = null; do { var request = new ScanRequest(tableName) { Limit = 1000, ExclusiveStartKey = result?.LastEvaluatedKey }; if (filterExpression != null) { request.SetFilterExpression(filterExpression); } result = client.ScanAsync(request).Result; // If LastEvaluatedKey is null, then the "last page" of results has been processed and there is no more data to be retrieved. // If LastEvaluatedKey is anything other than null, this does not necessarily mean that there is more data in the result set. // The only way to know when you have reached the end of the result set is when LastEvaluatedKey is null. foreach (AttributeCollection item in result.Items) { yield return(item.As <T>(metadata)); } }while (result.LastEvaluatedKey != null); }
public async Task <IList <T> > ScanAsync(IEnumerable <KeyValuePair <string, object> > startKey = null, Expression[] conditions = null, int take = 1000) { var request = new ScanRequest(tableName) { Limit = take }; if (conditions != null && conditions.Length > 0) { request.SetFilterExpression(DynamoExpression.Conjunction(conditions)); } if (startKey != null) { request.ExclusiveStartKey = AttributeCollection.FromJson(startKey.ToJson()); } var result = await client.Scan(request).ConfigureAwait(false); return(new QueryResult <T>(result)); }