sql server - Why does Linq-to-SQL add unnecessary COUNT()? -


here tables:

create table customer  (     cid int primary key,     name varchar(32) )  create table ord  (     oid int primary key,     cid int foreign key references customer,     address varchar(20) ) 

here's linq-to-sql statement:

var aaa = c in db.customer           select new { c, o = c.ord.tolist() }; 

and here's inexplicable query generated linq-to-sql:

select      [t0].[cid] [cid], [t0].[name] [name], [t1].[oid] [oid],      [t1].[cid] [cid2], [t1].[address] [address],      (select count(*)      [dbo].[ord] [t2]      [t2].[cid] = [t0].[cid]) [value] [dbo].[customer] [t0] left outer join [dbo].[ord] [t1] on [t1].[cid] = [t0].[cid] order [t0].[cid], [t1].[oid] 

i want understand how rid of count(*) part. it's entirely uncalled for!

linq needs count(*) in order determine number of entries returned o = c.ord.tolist().


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -