Created
October 24, 2012 16:05
-
-
Save bradoyler/3946983 to your computer and use it in GitHub Desktop.
Get ALL docs from any collection in RavenDB
This file contains 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
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