Last active
October 2, 2015 10:22
-
-
Save dtaalbers/32bf072e368262c2fdea to your computer and use it in GitHub Desktop.
Get all RavenDB documents from one document type (overcome 1024 limit)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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