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

Maven Crash Course - Learn Power Query, Power Pivot & DAX in 15 Minutes

"Data Prep & Exploratory Data Analysis" course by Maven Analytics

Oracle Cloud Infrastructure 2024 Generative AI Professional Course & Certification Exam (1Z0-1127-24)