读书人

linq left join 多条件如何写

发布时间: 2012-02-09 18:22:27 作者: rapoo

linq left join 多条件怎么写?
select a.*,b.* from a
left join b on a.type = b.type and a.item = b.item
where b.num > 3


请问转成linq应该怎么写?谢谢!

[解决办法]
数据库中的可空可以映射为int?
from a in A join b in B.DefaultIfEmpty()
on new{a.type,a.item} equals new{b.type, b.item}
where a.num > 3
select new{Type = a.type==0 ? 100 : a.type, ...,a, b}
可空类型直接用 ??
[解决办法]

探讨
select a.*,b.* from a
left join b on a.type = b.type and a.item = b.item
where b.num > 3


请问转成linq应该怎么写?谢谢!

读书人网 >.NET

热点推荐