c# - Getting null reference error in linq expression when trying to join more than 2 tables using defaultifempty method -


i trying left join 3 tables using defaultifempty assign null value if there no match in second table , using second table values join third table.

var test = (from eqpt in eqpts             join systemeqpt in fleetsyseqpt on systemeqpt.id equals eqpt.swcompanyeqptkey syseqpttemp             in syseqpttemp.defaultifempty()             join system in system on a.swfleetsystemkey equals system.id  ) 

i getting null object reference error when 'a' becomes null. suggestions check whether 'a' null while joining.

you need add where condition

var test = (from eqpt in eqpts             join systemeqpt in fleetsyseqpt on systemeqpt.id equals eqpt.swcompanyeqptkey syseqpttemp             in syseqpttemp.defaultifempty()             join system in system on a.swfleetsystemkey equals system.id              != null ) 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -