.net - Entity Framework Where(Func<Car, bool>) clause not going to server -


i want pass "where" clause method via method parameter have found clause not getting sent database server. query actual fetches of records , "where" applied ef in client application.

here example demonstrate problem:

// id  name         colour // ----------------------- // 3   red_car      red // 4   white_car    white // 5   blue_car     blue  using (qdbentities db = new qdbentities()) {     // #1 - no variable "where" - sent server, result correct.     foreach (var car in db.cars.where(r => r.colour == "red"))         console.writeline(car.id + " " + car.name);     // output:      3 red_car     // profiler:   ... [dbo].[car] [extent1]     // n'red' = [extent1].[colour]      // #2 - using variable "where" - not sent server, result correct.     func<car, bool> = new func<car, bool>(r => r.colour == "red");     foreach (var car in db.cars.where(where))         console.writeline(car.id + " " + car.name);     // output:      3 red_car     // profiler:    [dbo].[car] [extent1] ** no clause ** } 

you need pass expression tree where() ef can see convert sql.

change func<car, bool> expression<func<car, bool>>.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -