Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Microsoft recommend method or query syntax? [closed]

Does Microsoft Net Core 3 recommend method syntax or query syntax for Linq Entity Framework queries? This is a debate in our workplace, we are curious.

This is not Opinion based question, but fact, since I am looking for Microsoft recommendation, not people opinion . Thanks

like image 671
AlexRodgers Avatar asked Apr 13 '26 05:04

AlexRodgers


1 Answers

There's no need to recommend either. They're equivalent, in that query expressions are effectively "preprocessed" to method syntax.

I view it as very worthwhile to know both:

  • Queries with joins, grouping etc tend to be more readable with query expressions due to the transparent identifiers introduced by the compiler
  • Many queries either can't be represented in query expressions, or are simpler to read with method syntax

Learn both thoroughly, and use whichever is most appropriate for any given scenario.

like image 149
Jon Skeet Avatar answered Apr 15 '26 23:04

Jon Skeet



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!