我想知道通过多个字段连接两个表时如何在 Linq 中编写内部连接。
例如,假设这是 SQL 等价物:
SELECT tableOne.fieldThree
FROM table_One AS tableOne,
table_Two AS tableTwo,
WHERE
tableOne.fieldOne == tableTwo.fieldOne AND
tableOne.fieldTwo == tableTwo.fieldTwo;
我试过这个:
tableTwo.Join(tableOne,
two => new { two.fieldOne, two.fieldTwo },
one => new { one.fieldOne, one.fieldTwo },
(two, one) => one.fieldThree)
.ToList();
但是编译器显示一个错误,指出无法从使用中推断出该方法。
谢谢。