Skip to content

Instantly share code, notes, and snippets.

@scattered-code
Last active January 6, 2020 13:22
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/e138bdd8805b9d255c981c7a13c3d21a to your computer and use it in GitHub Desktop.
Save scattered-code/e138bdd8805b9d255c981c7a13c3d21a to your computer and use it in GitHub Desktop.
static async IAsyncEnumerable<Order> GetDocumentsFromDatabase2(IAsyncDocumentSession session)
{
var skip = 0;
do
{
var entries = await session.Query<Order>().OrderByDescending(x => x.Id).Skip(skip).Take(100).ToListAsync();
foreach (var entry in entries)
yield return entry;
skip += 100;
if (entries.Count < 100)
break;
} while (true);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment