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 };
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:
Is:
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!