0

I am not trying to join my table using left outer join in LINQ where one of my join conditions does not satisfy. How can I still get the default record in my dataset? My SQL query runs perfectly fine but my join query is not returning the data.

Below is my SQL query where my left outer join works fine:

 select 
  w.issueid as Issue
 from worklog w 
   join jiraissue as j on w.issueid=j.ID
   join issuetype AS ty ON ty.ID = j.issuetype
   join project AS p on p.ID=j.PROJECT
    left outer join customfieldvalue cfv on cfv.ISSUE = w.issueid

Below is my LINQ query in C# where if cfv.issue in the last join is not available in the table, I want to still return the default column.

  var data = (from w in worklogs
                    
                    join i in issuetypes on j.issuetype equals i.ID
                    join p in projects on j.PROJECT equals p.ID into table0
                    from c in table0.DefaultIfEmpty()
                    join cfv in customfieldvalues on w.issueid equals cfv.ISSUE into table1
                    from d in table1.DefaultIfEmpty()
                    {
                        IssueKey = l.Key.pkey + '-' + l.Key.issuenum,
                        Hours = l.Sum(w => w.timeworked)
                    }).ToList();           

Any help is appreciated. Thank you.

Pooja
  • 35
  • 5

0 Answers0