Skip to content

Instantly share code, notes, and snippets.

@bradoyler
Created October 24, 2012 16:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bradoyler/3946983 to your computer and use it in GitHub Desktop.
Save bradoyler/3946983 to your computer and use it in GitHub Desktop.
Get ALL docs from any collection in RavenDB
using Raven.Client;
public class RavenSearch
{
private IEnumerable<T> GetAllResults<T>(IDocumentSession session) where T : class
{
session.Advanced.MaxNumberOfRequestsPerSession = 1000;
int skip = 0;
var results = new List<T>();
var query = session.Query<T>();
var totalCount = query.Count();
while (skip < totalCount)
{
results.AddRange(query.Skip(skip).Take(1024).ToList());
skip += 1024;
}
return results;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment