I have a requirement where I need to fetch the entire data collection Users
from RavenDB and compare the retrieved result set with another set of data. There are cl
Building up on the Ayende answer, here is a complete method, that does overcome the problem of 30 queries per session and indeed return all documents of the supplied class:
public static List getAll(DocumentStore docDB) {
return getAllFrom(0, new List(), docDB);
}
public static List getAllFrom(int startFrom, List list, DocumentStore docDB ) {
var allUsers = list;
using (var session = docDB.OpenSession())
{
int queryCount = 0;
int start = startFrom;
while (true)
{
var current = session.Query().Take(1024).Skip(start).ToList();
queryCount += 1;
if (current.Count == 0)
break;
start += current.Count;
allUsers.AddRange(current);
if (queryCount >= 30)
{
return getAllFrom(start, allUsers, docDB);
}
}
}
return allUsers;
}
I hope it is not too hacky to do it like this.