예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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());
        }