query.Skip(page*pageSize).Take(pageSize);However, after some research I realized that this is inefficient and actually causes some issues because the query is performed in memory.
N.B. Sitecore uses a reduced set of Linq operators, be careful when refactoring Sitecore Linq statements as tools like reSharper will break Sitecore Linq statements
Instead the Sitecore suggested approach to do this is to use the Page extension method, that is part of the QueryableExtension class in Sitecore.Contentsearch.Linq.
The above would become:
query.Page(page, pageSize);Much neater!
Hi Nasreen, thanks for your nice comments!
ReplyDelete