我有这个sql select:
select a.*
from a inner join b on (a.col1=b.col1 and a.col2=b.col2)
让我们假设a,b现在是lists.Can你能帮我在带有lambda表达式的c#,Linq中编写这个select吗?
答案 0 :(得分:1)
您正在寻找的方法是
Enumerable.Join<TOuter, TInner, TKey, TResult>
,
见https://msdn.microsoft.com/en-us/library/bb534675(v=vs.110).aspx
答案 1 :(得分:0)
from a inner join b on (a.col1=b.col1 and a.col2=b.col2)
可以像这样转换成LINQ:
a.Join(b, aItem => aItem.col2, bItem => bItem.col2,
(aItem, bItem) => new { aItem = aItem, bItem = bItem, col2 = aItem.col2);