0

When allUserDepart is null other join fire a exception on line of join allDepartment. Because uD its null. How to fix this code?

join d in allDepartment on uD.DepartmentId equals d.DepartmentId into departmentJoin

--Ful Code is

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()
Emre Ekşioğlu
  • 359
  • 2
  • 13

0 Answers0