entity framework - Does LINQ to Entities expression with inner object context instance translated into sequence of SQL client-server requests? -


i have ado.net ef expression like:

db.table1.select(   x => new { ..., count = db.table2.count(y => y.foreignkey.id == x.id) }) 

does understand correctly it's translated several sql client-server requests , may refactored better performance?

thank in advance!

yes - expression translated (in best way can) sql query.

and t-sql query, ef (or l2sql) query expression can refactored performance.

why not run sql profiler in background see getting executed, , try , optimize raw t-sql first - optimize expression.

or if have linqpad, optimize t-sql query , linqpad write query you.

also, im not sure why have specified delegate count() expression.

you can this:

var query= c in db.table1                   select new { c.customerid, ordercount = c.table2s.count() }; 

Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -