Skip to main content

How to Use Skip Tokens to Optimize Paging

This topic presents examples that demonstrate how to use skip tokens to optimize paging.

VirtualSourcesSkipTokens

Complete Examples

Remarks

Using skip tokens, you can get the next page based on the previous one. It improves the performance of obtaining the next page.

In the following code sample, the lastId is a skip token:

var firstPage = queryable
    .OrderBy(x => x.Id)
    .Take(20)
    .ToArray();

var lastId = firstPage.Last().Id;
var secondPage = queryable
    .Where(x => x.Id > lastId)
    .OrderBy(x => x.Id)
    .Take(20)
    .ToArray();