Esempio n. 1
0
        public List <T> Scan <T>(ScanExpression <T> 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);
        }
Esempio n. 2
0
        public static async Task <List <T> > ScanIntoAsync <T>(this IPocoDynamo db, ScanExpression request, int limit, CancellationToken token = default)
        {
#if NET472 || NETCORE
            return(await db.ScanAsync <T>(request.Projection <T>(), limit : limit, token : token).ToListAsync(token));
#else
            return(await db.ScanAsync <T>(request.Projection <T>(), limit : limit, token : token).ConfigAwait());
#endif
        }
Esempio n. 3
0
        public ScanExpression <T> FromScan <T>(Expression <Func <T, bool> > filterExpression = null)
        {
            var q = new ScanExpression <T>(this)
            {
                Limit          = PagingLimit,
                ConsistentRead = !typeof(T).IsGlobalIndex() && this.ConsistentRead,
            };

            if (filterExpression != null)
            {
                q.Filter(filterExpression);
            }

            return(q);
        }
Esempio n. 4
0
        public ScanExpression <T> FromScanIndex <T>(Expression <Func <T, bool> > filterExpression = null)
        {
            var table = typeof(T).GetIndexTable();
            var index = table.GetIndex(typeof(T));
            var q     = new ScanExpression <T>(this, table)
            {
                IndexName      = index.Name,
                Limit          = PagingLimit,
                ConsistentRead = !typeof(T).IsGlobalIndex() && this.ConsistentRead,
            };

            if (filterExpression != null)
            {
                q.Filter(filterExpression);
            }

            return(q);
        }
Esempio n. 5
0
        public virtual IEnumerable <T> GetResults(ScanExpression scanExpr, int?skip = null, int?take = null)
        {
            var results = db.Scan(scanExpr, r =>
            {
                if (total == null)
                {
                    total = r.Count;
                }
                return(r.ConvertAll <T>());
            });

            if (skip != null)
            {
                results = results.Skip(skip.Value);
            }

            if (take != null)
            {
                results = results.Take(take.Value);
            }

            return(results.ToList());
        }
Esempio n. 6
0
 public IEnumerable <T> Scan <T>(ScanExpression <T> request)
 {
     return(Scan(request, r => r.ConvertAll <T>()));
 }
Esempio n. 7
0
 public static List <T> ScanInto <T>(this IPocoDynamo db, ScanExpression request, int limit)
 {
     return(db.Scan <T>(request.Projection <T>(), limit: limit));
 }
Esempio n. 8
0
 public static IEnumerable <T> ScanInto <T>(this IPocoDynamo db, ScanExpression request)
 {
     return(db.Scan <T>(request.Projection <T>()));
 }