Выражение Linq множественная левая внешняя ошибка соединения

Я не могу выполнить ниже linq.

   var items(  from p in Patients 
    join q in MURWorksheets on p.PatientId equals q.PatientId into step1
    from s in step1.DefaultIfEmpty()
    join t in MURWorksheetAnswers on s.MURWorksheetId equals t.MURWorksheetId into step2


    from s2 in step2.DefaultIfEmpty()

    select new {p.FirstName , Date = (s.MURDate == null ? DateTime.Now.Date : s.MURDate),
    s2.MURQuestionnaireId,s2.MURExpctedAnswersId}).ToList();

Вот sql для того же для вашей справки.

select a.FirstName,b.MURDate,c.MURQuestionnaireId,c.MURWorksheetAnswersID from Patients as a
left join MURWorksheet as b on a.PatientId = b.PatientId
left join MURWorksheetAnswers as c on b.MURWorksheetId = c.MURWorksheetId

1 ответ

Решение

Вы пропустили знак равенства в своем вставленном коде:

var items = (from p in Patients 
    join q in MURWorksheets on p.PatientId equals q.PatientId into step1
    from s in step1.DefaultIfEmpty()
    join t in MURWorksheetAnswers on s.MURWorksheetId equals t.MURWorksheetId into step2


    from s2 in step2.DefaultIfEmpty()

    select new {p.FirstName , Date = (s.MURDate == null ? DateTime.Now.Date : s.MURDate),
    s2.MURQuestionnaireId,s2.MURExpctedAnswersId}).ToList();
Другие вопросы по тегам