我在linq中有以下代码,我想要做的是连接一个表的多列的表
//NOT A VALID CODE
from t1 in table1
join t2 in table2 on ((t1.ID equals t2.orderId) || (t1.ID equals t2.pickupId ))// how can I do this
...
...
我如何在Linq中实现这一目标?
答案 0 :(得分:3)
使用匿名类型
from t1 in table1
join t2 in table2 on new { t1.ID, t1.pickupId } equals new { t2.ID, t2.pickupId }
...
答案 1 :(得分:1)
var query = from t1 in table1
from t2 in table2
where t1.ID == t2.orderId || t1.ID == t2.pickupId
select new { t1, t2};