Skip to content

Instantly share code, notes, and snippets.

@dtaalbers
Last active October 2, 2015 10:22
Show Gist options
  • Save dtaalbers/32bf072e368262c2fdea to your computer and use it in GitHub Desktop.
Save dtaalbers/32bf072e368262c2fdea to your computer and use it in GitHub Desktop.
Get all RavenDB documents from one document type (overcome 1024 limit)
public List<DocType> DoStuffForALotOfData()
{
var list = new List<DocType>();
using (var session = _DataContext.OpenSession())
{
var skip = 0;
var take = 50;
// Execute query
var query = session.Query<DocType>()
.Skip(skip)
.Take(take);
while (query.Any())
{
// TODO: Do you stuff here
list.AddRange(query);
// Update the skip for the next query
skip += take;
// Fetch a new batch of docs
query = session.Query<DocTypes>()
.Skip(skip)
.Take(take);
}
return list;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment