目的實現:spa
select id,name,jname,cname from userinfo u left join job j on u.job=j.jid left join city c on u.city=c.cid 多表left join對象
代碼以下:ci
var list = (from u in dc.userinfos
join j in dc.jobs on u.job equals j.jid into j_join
from x in j_join.DefaultIfEmpty()
join c in dc.cities on u.city equals c.cid into c_join
from v in c_join.DefaultIfEmpty()
select new
{
id=u.id,
name=u.name,
jname=x.jname,
cname=v.cname,
/*u1=u,x1=x,v1=v*///不要用對象的方式 由於對象可能爲null那麼對象.屬性就會拋異常
}).ToList();it