I would like to know how I can write an inner join in Linq when joining two tables through more than one field.
For example, say this is the SQL equivalent:
SELECT tableOne.fieldThree
FROM table_One AS tableOne,
table_Two AS tableTwo,
WHERE
tableOne.fieldOne == tableTwo.fieldOne AND
tableOne.fieldTwo == tableTwo.fieldTwo;
I tried this:
tableTwo.Join(tableOne,
two => new { two.fieldOne, two.fieldTwo },
one => new { one.fieldOne, one.fieldTwo },
(two, one) => one.fieldThree)
.ToList();
But the compiler shows an error that says the method cannot be inferred from usage.
Thanks.