vb.net - Linq nested Join from a group join if null -
i'm sure simple life of me cannot find single example of this.
i doing group join on table want second join on grouped join.
table 1 orders table 2 contacts table 3 phone numbers
dim query = order in orders _ group join contact in contacts on order.contactid equals contact.contactid grpcontacts = group gcontact in grpcontacts.defaultifempty() group join phone in phonenumbers on phone.phonenumberid equals gcontact.homephoneid grpphonenumbers = group gphone in grpphonenumbers.defaultifempty()
this query error out on last join when gcontact null. makes sense... how do join anyway , have null/nothing values if record not exist?
update resolved * if else runs can add expression after on operator determine if previous group join nothing. moander!
dim query = order in orders _ group join contact in contacts on order.contactid equals contact.contactid grpcontacts = group gcontact in grpcontacts.defaultifempty() group join phone in phonenumbers on if(phone nothing, 0, phone.phonenumberid) equals gcontact.homephoneid grpphonenumbers = group gphone in grpphonenumbers.defaultifempty()
try using iif avoid accessing gcontact when null:
equals iif(gcontact nothing, 0, gcontact.homephoneid)
Comments
Post a Comment