I have a method on my generated partial class like this:
var pChildren = this.Children
.Skip(skipRelated)
.Take(takeRelated)
.ToList();
Does it help if you call Skip
on the result of Take
? i.e.
table.Take(takeCount+skipCount).Skip(skipCount).ToList()
Also, see
The problem is that you are performing a LINQ-to-Object query when you query a child collection like that. EF will load the whole collection and perform the query in memory.
If you are using EF 4 you can query like this
var pChildren = this.Children.CreateSourceQuery()
.OrderBy(/* */).Skip(skipRelated).Take(takeRelated);
In EF 4.1
var pChildren = context.Entry(this)
.Collection(e => e.Children)
.Query()
.OrderBy(/* */).Skip(skipRelated).Take(takeRelated)
.Load();