0

I am not very good with linq, seems kind of confusing to me, but I have been making my way through it. I have the following query that I can't seem to get to work.

I get the error:

The value for column 'empl_cctr_id' in table 'temsempl' is dbnull.

The other join might also get the same error as well but with that related tables. Please help.

Dim query = (From empl In EMS_DS.TEMSEMPL
             Join cctr In EMS_DS.TEMSCCTR On empl.empl_cctr_id Equals cctr.cctr_id
             Join ppcd In EMS_DS.TEMSPPCD On empl.empl_ppcd_id Equals ppcd.ppcd_id
             Where empl.empl_userid.Equals(text.ToString.ToUpper)
             Select empl.empl_sep_dt, cctr.cctr_cd, ppcd.ppcd_desc).ToList
Bizley
  • 17,392
  • 5
  • 49
  • 59
dk96m
  • 301
  • 3
  • 18
  • Have a look into [this](http://stackoverflow.com/questions/5696888/linq-join-tables-on-nullable-columns). It might help. – Bugs Oct 28 '16 at 13:05
  • Yea, I saw and tried those suggests, but that didnt work. My problem is in the join on i think – dk96m Oct 28 '16 at 13:11
  • Yes it looks like it. The accepted answer in that link has two examples. Have you tried the second? – Bugs Oct 28 '16 at 13:12

1 Answers1

0

Dim query = (From empl In EMS_DS.TEMSEMPL Join cctr In EMS_DS.TEMSCCTR On empl.empl_cctr_id Equals cctr.cctr_id into temp from cctr in temp.DefaultIfEmpty() Join ppcd In EMS_DS.TEMSPPCD On empl.empl_ppcd_id Equals ppcd.ppcd_id Where empl.empl_userid.Equals(text.ToString.ToUpper) Select empl.empl_sep_dt, cctr.cctr_cd, ppcd.ppcd_desc).ToList

  • 2
    While this code fragment may answer the OP's question, the answer would be much more useful for future visitors if you explain why it should solve the problem. – Gert Arnold Oct 29 '16 at 15:05