猿问

SQL 转 Linq

select a.column1,a.column2,
(select t.column3 from table2 as t where t.id=a.id) as column3,
(select b.column4 from table3 as b where b.id=a.id) as colunm4
from table1 as a

这样的SQL查询用Linq怎么写啊?

一只名叫tom的猫
浏览 324回答 1
1回答

沧海一幻觉

var query= from a in db.table1 select new {a.column1,a.column2, column3= db.table2.FirstOrDefault(f=>f.id==a.id).column3 , column4= db.table3.FirstOrDefault(f=>f.id==a.id).column4 , };        
随时随地看视频慕课网APP
我要回答