public List <T> Scan <T>(ScanRequest request, int limit) { var to = new List <T>(); if (request.Limit == default(int)) { request.Limit = limit; } ScanResponse response = null; do { if (response != null) { request.ExclusiveStartKey = response.LastEvaluatedKey; } response = Exec(() => DynamoDb.Scan(request)); var results = response.ConvertAll <T>(); foreach (var result in results) { to.Add(result); if (to.Count >= limit) { break; } } } while (!response.LastEvaluatedKey.IsEmpty() && to.Count < limit); return(to); }
public DynamoDbResult <T> ScanPage <T>(ScanExpression <T> request, int limit, Dictionary <string, AttributeValue> lastEvaluatedKey = null) { var result = new DynamoDbResult <T>(); request.Limit = limit; ScanResponse response = null; if (lastEvaluatedKey != null) { request.ExclusiveStartKey = lastEvaluatedKey; } response = Exec(() => DynamoDb.Scan(request)); var results = response.ConvertAll <T>(); result.Data = results; result.LastEvaluatedKey = response.LastEvaluatedKey; return(result); }
public IEnumerable <T> Scan <T>(ScanRequest request, Func <ScanResponse, IEnumerable <T> > converter) { ScanResponse response = null; do { if (response != null) { request.ExclusiveStartKey = response.LastEvaluatedKey; } response = Exec(() => DynamoDb.Scan(request)); var results = converter(response); foreach (var result in results) { yield return(result); } } while (!response.LastEvaluatedKey.IsEmpty()); }