关于linq to entity Left join 的问题
select * from [table1] a
left join [table2] b on a.ID = b.ID
left join [table3] c on a.ID = c.ID
left join [table4] c on a.ID = c.ID
.....
...
如何转换成LinQ啊...
貌似用了Linqer也没用
[最优解释]
from c in table1
join p in table2 on c.ID equals p.PID into t1
from p in t1.DefaultIfEmpty()
join d in table3 on p.EID equals pi.PIID into t2
from d in t2.DefalutIfEmpty()
select c;
[其他解释]
from c in table1
join p in table2 on c.ID equals p.PID
join d in table3 on p.EID equals pi.PIID
select new
{
c.ID, p.PID, pi.PIID
}
var result = (from a in table1
join b in table2 on a.a_guid equals b.b_guid into t1
from b in t1.DefaultIfEmpty()
join c in table3 on a.a_guid equals c.c_guid into t2
from c in t2.DefaultIfEmpty()
join e in table4 on a.a_userid equals e.e_userid into t3
from e in t3.DefaultIfEmpty()
orderby a.CreateWhen
select new {....});
select new
{
a,
b,
c,
e
//DynamicGUID = a.DynamicGUID,
//DynamicType = a.DynamicType,
//CreateWhen = a.CreateWhen,
//UserID = e.UserID,
//UserGUID = e.UserGUID,
//Avatar = e.Avatar,
//Name = e.Name,
//Body = b.Body,
//SimpleCategory = c.SimpleCategory,
//IndustryCategory = c.IndustryCategory,
//AreaCategory = c.AreaCategory,
//JobCategory = c.JobCategory,
//DepartmentCategory = c.DepartmentCategory,
//BusinessDescription = c.BusinessDescription
});