Thursday, 13 July 2017

Paging a collection with LINQ

Question: How do you page through a collection in LINQ given that you have a startIndex and a count?

Solution:  Following natural way of paginating a LINQ collection.

var query = from i in ideas
            select i;
var pagedCollection = query.InPagesOf(10);
var pageOfIdeas = pagedCollection.Page(2);

No comments:

Post a Comment