Reputation: 67918
Okay, right now I've got this statement and it's working well (note I've already sorted the list before executing this statement so Reverse
is simply allowing me to pop off the last page):
return results.Take(pageSize * pageIndex).Reverse().Take(pageSize);
But there's got to be a more efficient way ... can anybody show me the way?
Thanks!
Upvotes: 2
Views: 941
Reputation: 2760
You should probably use Skip
return results.Skip(pageSize * pageIndex).Take(pageSize);
Upvotes: 3
Reputation: 9858
There is a Skip operator.
Bypasses a specified number of elements in a sequence and then returns the remaining elements. http://msdn.microsoft.com/en-us/library/bb358985.aspx
For example:
return results.Skip(pageSize * pageIndex).Take(pageSize);
Upvotes: 6