linq join on 多个关联条件
sqlserver语句:
select * from Table1 join Table2
on Table1.Col1=Table2.Col1 and Table1.Col2=Table2.Col2
对应linq写法:
一:
var Infos = from a in Table1 join b in Table2
on new { a.Col1 , Col2 } equals new { b.Col1 , b.Col2}
select new { a.Col1, b.Col2 };
二:
var userInfos = from a in Table1
from b in Table2
where a.Col1 == b.Col1 && a.Col2 == b.Col2
select new { a.Col1, b.Col2 };