Entity Framework allows you to choose a range.

c# entity-framework linq-to-entities


I'm having trouble attempting to improve our listview's page-based performance.

I want the entity framework to do a select statement but only return the items from one page of the listview as the range of the results.

I looked for this on Google but came up empty-handed. I just discovered that I can. ToList(). GetRange(start index, finish index), however it would load every item into memory, which I would want to avoid.

Can someone let me know whether this is possible? Given that our listview must be reusable, I don't want to utilize a stored method, view, or anything similar.


5/4/2011 7:09:18 AM

Accepted Answer

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

I'm sorry, but.Skip(startPosition).Take(numberOfItems).ToList()

5/4/2011 7:12:32 AM

Popular Answer

In order to avoid loading the whole collection before applying filters, use Query() before Load() if you are not utilizing lazy loading:

    .Collection(b => b.Posts) 

It is often recommended to disable lazy loading for the navigation property when utilizing the query approach. This is necessary because, in the alternative, the lazy loading method may automatically load the full collection either before or after the filtered query has been run.

the following number: http://msdn.microsoft.com/en-us/data/jj574232.aspx

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow