Lambda overload for passes / withdrawals

I had a very simple test code to look at the effects of constants in linq queries, and I had trouble finding overload ...

This MSDN article specifically mentions lambda overload for skipping / accepting, however I cannot find it.

From section 4.2 Performance Recommendations for Entity Framework 4, 5, and 6 :

"In particular, note the use of Skip and Take when paging. In EF6, these methods have lambda overloads that effectively make the cached query plan reusable, since EF can capture the variables passed to these methods and translate them into SQLparameters."

They follow this code example:

var customers = context.Customers.OrderBy(c => c.LastName); for (var i = 0; i < count; ++i) { var currentCustomer = customers.Skip(() => i).FirstOrDefault(); ProcessCustomer(currentCustomer); } 

My test code is:

 for(int i = 0; i<100; i++) { var result = dc.Products //.Select(p => p.Name) .OrderBy(p => p.Name) .Skip(() => i) .ToList(); } 

Error: cannot convert lambda expression to input 'int' because it is not a delegate type

Am I really not reading, or is it missing somewhere with an overloaded extension method? I am on EF 6.1.1.

+7
c # linq entity-framework-6
source share
1 answer

The extension method you are looking for is " QueryableExtensions.Skip ". It is located in the System.Data.Entity namespace in the EntityFramework assembly.

+14
source share

All Articles