How to rewrite this LINQ using join with lambda expressions?

join, lambda, linq

Solution

I prefer the "LINQ syntax" for Joins as I think it looks cleaner.

In any case, here is how to translate the LINQ-join to the "Lambda Expression"-join.

The translation for:

from a in AA
join b in BB on
a.Y equals b.Y
select new {a, b}

Is:

AA.Join(                 // L
  BB,                    // R
  a => a.Y, b => b.Y,    // L -> join value, R -> join value
  (a, b) => new {a, b})  // L+R result

The other LINQ keywords are much simpler to convert (e.g. `OrderBy(u => u.DisplayOrder)` and are just "chained together" with `.`. - give it a go!

Problem

It seems like most LINQ is written with lambda expressions. How do I go about rewriting this linq using lambda, kinda confusion with the style (especially with joins)? ``` var responses = from c in questionRepository.GetReponses() join o in questionRepository.GetQuestions() on c.QuestionID equals o.QuestionID where c.UserID == 9999 orderby o.DisplayOrder select new { o.QuestionText, c.AnswerValue }; ```

Original source