Exemplo n.º 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);
        }
Exemplo n.º 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);
        }