Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select a range with Entity Framework

I have an issue trying to maximize the performance of our listview that has pages.

I want the entity framework to do a select statement, but only return a range of the result (range = the items of one page of the listview).

I have searched google but didn't find any results on this. I only found that I can do a .ToList().GetRange(start index, end index), but then all items would be loaded in memory, and that is what I would like to avoid...

Can someone tell me if this can be done? (I don't want to use a stored procedure or view or something like that because our listview has to be reusable...)

Thanks!

like image 488
Jonas Verdickt Avatar asked May 04 '11 07:05

Jonas Verdickt


1 Answers

You should be able to use .Take(x).ToList()

edit: sorry, try .Skip(startPosition).Take(numberOfItems).ToList()

like image 128
Kirk Broadhurst Avatar answered Oct 02 '22 15:10

Kirk Broadhurst