Paging a collection with LINQ

Just how do you web page via a collection in LINQ considered that you have a startIndex and also a count?

0
2019-05-07 00:19:28
Source Share
Answers: 2

A couple of months back I created a post concerning Fluent Interfaces and also LINQ which made use of an Extension Method on IQueryable<T> and also an additional class to give the adhering to all-natural means of paginating a LINQ collection.

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

You can get the code from the MSDN Code Gallery Page : Pipelines, Filters, Fluent API and LINQ to SQL.

0
2019-05-13 13:13:11
Source

It is really straightforward with the Skip and also Take expansion approaches.

var query = from i in ideas
            select i;

var paggedCollection = query.Skip(startIndex).Take(count);
0
2019-05-08 20:32:36
Source