Which LINQ syntax is better?

There are multiple ways to write a LINQ query in C#:
  • Use query (comprehension) syntax.
  • Use method or Lambda syntax or Fluent syntax.
  • Use a combination of query syntax and method syntax.
So which syntax is better?

MSDN recommends writing most queries using query syntax to create query expressions. The general opinion in this StackOverflow thread seems to be - "it depends".

One Lambda syntax fan converted the MSDN 101 LINQ Samples which were in query syntax to Lambda syntax using LinqPad.

Comments

Popular posts from this blog

From Stiff Chatbot to Savage Sidekick: The UI/UX Glow-Up Story

GitHub Copilot Certification Exam Prep

HOW TO add a header or footer to a dynamically generated Word document