当allUserDepart为null时,其他联接将在联接allDepartment的行上引发异常。因为uD为null。如何修复此代码?
join d in allDepartment on uD.DepartmentId equals d.DepartmentId into departmentJoin
-完整代码为
var data = (from us in allUsers
join uR in allUserRoles on us.UserId equals uR.UserId into userRoleJoin
from uR in userRoleJoin.DefaultIfEmpty()
join r in allRoles on uR.RoleId equals r.RoleId
join uD in allUserDepartment on us.UserId equals uD.NewUserId into userDepJoin
from uD in userDepJoin.DefaultIfEmpty()
join d in allDepartment on uD.DepartmentId equals d.DepartmentId into departmentJoin
from d in departmentJoin.DefaultIfEmpty()