LINQ EF 多外键关联
比如
class a {string Name;int a1;int a2;b b;}
class b {string Name;int b1;int b2;}
a和b是通过a1 = b1 还有a2 = b2两个条件关联的,实体上要如何定义?
------解决方案--------------------from a in tablea
join b in tableb on new { a = a.a1, b = a.b1 } equals new { a = b.a1, b = b.b1 }
select a
http://www.codeproject.com/Articles/262949/Linq-Join-on-Mutiple-columns-using-Anonymous-type
------解决方案--------------------var data = from a in tableA
join b in tableB
on new { a.a1,a.a2 }
equals new { b.b1,b.b2 }
into x
from cx in x.DefaultIfEmpty()
select new
{
a,b
};