Reputation: 61
SELECT a.c1, a.c2, b.c1, b.c2
FROM tab1 a, tab2 b
WHERE a.a1 = b.a1 AND a.b1 = b.b2;
I need help converting above to Linq-To-Sql syntax.
The problem line is
WHERE a.a1 = b.a1 AND a.b1 = b.b2
If it is only one condition, it is easy.
var myQry =
from a in tab1
join b in tab2 on a.a1 == b.a1
I need help completing myQry!
Upvotes: 0
Views: 51
Reputation: 149078
You can join on multiple columns like this:
var myQry =
from a in tab1
join b in tab2 on new { a.a1, a.b1 } equals new { b.a1, b.b2 }
select new { a.c1, a.c2, b.c1, b.c2 }
Or in fluent syntax:
var myQuery = tab1.Join(tab2,
a => new { a.a1, a.b1 },
b => new { b.a1, b.b2 },
(a, b) => new { a.c1, a.c2, b.c1, b.c2 });
Upvotes: 1