日期:2014-05-20  浏览次数:20733 次

linq 左连接
Table1 
ID int PK
Col1 varchar(50)
Col2 int
======================================
Table2
ID int PK
oID int FK
Remarks varchar(50)
======================================
Table1 数据  
1 2 3  
2 4 4
3 3 3
Table2 数据  
2 4 4
3 3 3
把 这个 select * from table1 left join table2 on table1.ID=table2.oID 这个换成
linq 语句怎么写 我只会用 内连接的。
左连接 不用了 刚在学 LINQ,不要见笑。




------解决方案--------------------
参考
C# code

select * from table1 left  join table2 on table1.ID=table2.oID 


from a in table1 
join b in table2 on a.IDequals(b.ID)
into x
from cx in x.DefaultIfEmpty()
select cx

------解决方案--------------------
探讨
参考
C# codeselect*from table1 leftjoin table2on table1.ID=table2.oIDfrom ain table1join bin table2on a.IDequals(b.ID)into xfrom cxin x.DefaultIfEmpty()select cx

------解决方案--------------------
lamda 语言~