나는 왼쪽으로 SQL에 linq에 가입, 내 질문은 오른쪽 테이블 필드를 선택하는 동안, 나는 각 필드 wheather 가입 된 개체를 확인 해요 null이든 아니든, 올바른 방법입니까? 아니면 다른 방법으로 그것을 할 수 있습니까? 내 쿼리linq SQL 왼쪽 테이블 조인, 오른쪽 테이블에 null을 확인해야합니다
from u in user
join x in employeee on u.id equals x.userId
into ux from ujoinx in ux.DefaultIfEmpty()
join y in department on x.id equals y.employeeId
into xy from xjoiny in xy.DefaultIfEmpty()
select new {
EmployeeSal = ujoinx!=null?ujoinx.employeeSal:0, // see checkig for null
EmployeeTax = ujoinx!=null?ujoinx.employeeTax:0, // in this 3 lines
UserName = u.username,
DeptName = xjoiny!=null?xjoiny.name:"" //is this a correct way ?
}
처럼 제대로 대답을 결과 쿼리입니다하지만 난 널 그것 object reference not set.....error
을 던지는 그 몇 가지 필드를 확인 해달라고합니다. 여기 정확히 무엇입니까 DefaultIfEmpty()
doin 정확히 ??
감사합니다. 실제로 각 필드에 null이 있는지 확인해야하기 때문에 꽤 많은 수의 필드가 있습니다. 다소 더러운 프로그래밍을 느꼈으 므로 거기에 다른 방법이 있습니다. – Meson