Paging

Paging is the process of splitting a set of results into pages and reading one page at a time. This is useful for optimizing bandwidth traffic, optimizing hardware usage, or simply because no user can handle huge amounts of data at once.

Safe By Default

The default value of the page size on the client side is 128.

Take

In order to overwrite the default page size use the Take method:

List<FileHeader> results = await session.Query()
							.Take(10)
							.ToListAsync();

Skip

Use the Skip method to specify the number of results to skip to be able to get the results from the next pages:

List<FileHeader> results = await session.Query()
							.Skip(10)
							.ToListAsync();

Example

The following code retrieves all files; each page contains no more that 10 items:

const int pageSize = 10;
int start = 0;
List<FileHeader> results;

do
{
	results = await session.Query()
							.Skip(start)
							.Take(pageSize)
							.ToListAsync();

	start += pageSize;

} while (results.Count == pageSize);