Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

linq to sql: join multiple columns from the same table

How do I inner join multiple columns from the same tables via Linq?

For example: I already have this...

join c in db.table2 on table2.ID equals table1.ID

I need to add this...

join d in db.table2 on table2.Country equals table1.Country 
like image 862
Pete Haas Avatar asked Dec 05 '08 22:12

Pete Haas


1 Answers

This is the only way I was able to get it to work (in c#).

var qry = from t1 in table1
          join t2 in table2
          on new {t1.ID,t1.Country} equals new {t2.ID,t2.Country}
          ...
like image 172
Pete Haas Avatar answered Sep 30 '22 20:09

Pete Haas