我的加入 linq 表达式就像以下
var kycKist = (from aloc in this._classesDataContext.tblUsers
join sup in this._classesDataContext.BR_Supervisors on aloc.SupId equals sup.Id
where
(aloc.UserTypesId == 1 &&
((aloc.CreatedOn <= attendanceDate && aloc.ModifyOn >= attendanceDate &&
aloc.Active == false) ||
(aloc.Active == true && aloc.CreatedOn <= attendanceDate &&
aloc.ModifyOn <= attendanceDate)))
select
new
{
sup.Name,
sup.Region,
sup.Area,
sup.Distribution_Name,
sup.BR_Alloc,
sup.Active
}).ToList();
现在我想用上面的代码做一个外连接
left outer join atn in this._classesDataContext.BR_Attendence on sup.ID equals atn.SupId where atn.date =attendanceDate
我的草稿代码看起来像这样
var kycKist = (from aloc in this._classesDataContext.tblUsers
join sup in this._classesDataContext.BR_Supervisors on aloc.SupId equals sup.Id
left outer join atn in this._classesDataContext.BR_Attendence on sup.ID equals atn.SupId where atn.date =attendanceDate
where
(aloc.UserTypesId == 1 &&
((aloc.CreatedOn <= attendanceDate && aloc.ModifyOn >= attendanceDate &&
aloc.Active == false) ||
(aloc.Active == true && aloc.CreatedOn <= attendanceDate &&
aloc.ModifyOn <= attendanceDate)))
select
new
{
Present=(atn!=null)?atn.PresentBR:0,
sup.Name,
sup.Region,
sup.Area,
sup.Distribution_Name,
sup.BR_Alloc,
sup.Active
}).ToList();
如何实现上面的左外连接?