Skip to content

Instantly share code, notes, and snippets.

@scattered-code
Last active January 6, 2020 13:24
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 scattered-code/ed22ee8003793d4f6b0ad01f123b9e20 to your computer and use it in GitHub Desktop.
Save scattered-code/ed22ee8003793d4f6b0ad01f123b9e20 to your computer and use it in GitHub Desktop.
public static IEnumerable<Entry> GetDocumentsFromDatabase(IDocumentSession session)
{
var skip = 0;
do
{
var entries = session.Query<Entry>().Where(x => !x.Deleted).OrderByDescending(x => x.DateModified).Skip(skip).Take(1024).ToList();
foreach (var entry in entries)
yield return entry;
skip += 1024;
if (entries.Count < 1024)
break;
} while (true);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment