RavenDB GetAll extension method

RavenDB GetAll extension method

        public static IEnumerable GetAll(this IDocumentStore documentStore)         {             var results = new List();             var documentSession = documentStore.OpenSession();             RavenQueryStatistics ravenQueryStatistics = null;             Func<IDocumentSession> getDocumentSession = () => documentSession.Advanced.NumberOfRequests == 30 ? documentSession = documentStore.OpenSession() : documentSession;             while (ravenQueryStatistics == null || results.Count < ravenQueryStatistics.TotalResults)                 results.AddRange(getDocumentSession().Query().Statistics(out ravenQueryStatistics).Take(1024).Skip(results.Count).ToArray());             return results;         }

This article is part of the GWB Archives. Original Author: Jon Canning

New on Geeks with Blogs