public static IRavenQueryable <T> Page <T>(this IRavenQueryable <T> that, RavenPageBookmark bm) { if (bm.CurrentPage > 0) { return((IRavenQueryable <T>) that .Statistics(out bm.Statistics) .Skip((bm.CurrentPage * bm.PageSize) + bm.LastSkippedResults) .Take(bm.PageSize)); } else { return((IRavenQueryable <T>) that .Statistics(out bm.Statistics) .Take(bm.PageSize)); } }
public static IEnumerable <T> GetAllUnSafe <T>(this IRavenQueryable <T> that, int pgSize = 1024) { RavenPageBookmark pbm = new RavenPageBookmark(pgSize); IEnumerable <T> currentPageResults = Enumerable.Empty <T>(); IEnumerable <T> aggregatedResults = null; do { currentPageResults = that.Statistics(out pbm.Statistics).Page(pbm).ToArray(); aggregatedResults = (null == aggregatedResults) ? currentPageResults : aggregatedResults.Concat(currentPageResults); pbm.Forward(); } while (pbm.More && currentPageResults.Any()); return(aggregatedResults); }