如何使用左外连接将此查询转换为linq

时间:2016-04-06 10:30:15

标签: linq c#-4.0

我在将此查询转换为linq时获得了不同的记录集。任何人都可以帮助我。

select p.Id  , p.lastname    from Participants p
left outer  join  CertificationStatusLevels c on p.CertificationStatusID = c.ID
left outer           join   BUOrgs po on p.PrimaryOrgID = po.ID
inner   join participantRoles pr on  p.id= pr.ParticipantId
inner join roles Ro on pr.RolesId=Ro.id
where p.IsActive =1   and ro.id=4 and  pr.IsActive =1

查询

from p in _unitOfWork.Context.Participants
join c in _unitOfWork.Context.CertificationStatusLevels on 
p.CertificationStatusID equals c.ID into pc
join po in _unitOfWork.Context.BUOrgs on p.PrimaryOrgID equals po.ID into bp
join pr in _unitOfWork.Context.ParticipantRoles on p.Id equals
pr.ParticipantId
join ro in _unitOfWork.Context.Roles on pr.RolesId equals ro.Id
from Combined1 in pc.DefaultIfEmpty()
from Combined2 in bp.DefaultIfEmpty()

0 个答案:

没有答案