I usually prefer the extension methods, because they i find them easier to read, but after seeing the answer by Erno to this question I was wondering how the minimum query would look with only extension methods used?
And more generally, are there queries that you can create in one form but not the other, or are both approaches equivalent?
There’s nothing you can do in query expressions which can’t be done without query expressions – query expressions are just translated into non-query-expression code anyway. There are plenty of queries that can’t be written in query expressions though… for example, anything using the
Selectoverload which provides the index as well:… and of course, all the many operators which aren’t supported by query expressions at all (
Firstetc).The “minimum” query would use
SelectManyfor the secondfromclause,Selectfor theletclause (introducing a new transparent identifier),Wherefor thewhereclause, andSelectfor theselectclause.