我知道Linq的左连接类似于这样:
var q=from e in db.Employes
join o in db.Orders on e equals o.Emoloyee into ords
from on in ords.DefautIfEmpty()
select new
{
e.FirstName,
e.LastName
};
那么多重连接怎么办?以下是我的代码。
var personalInfoQuery = from t in crnnsupContext.Tombstones
join p in crnnsupContext.ProvStates on t.ProvinceState equals p.ProvinceStateID
join n in crnnsupContext.NursingSchools on t.NursingSchool equals n.SchoolID
join i in crnnsupContext.InitialEducations on t.InitialEducation equals SqlFunctions.StringConvert((double)i.InitalEducationID, 1)
join g in crnnsupContext.tbl_GraduatedProvCountry on t.GradPovCountry equals g.id
where t.RegNumber == _username
select new CPersonalInfo
{
ProvState = p,
Tombstone = t,
NursingSchool = n,
InitialEducation = i,
GraduatedProvCountry = g,
};
每个加入的表都可能有“null”字段。能帮我解决吗,谢谢。