score:7

Accepted answer

if you've only got one or two clauses, i'd go for "dot notation". when you start doing joins, groupings, or anything else that introduces transparent identifiers, query syntax starts to appeal a lot more.

it's often worth trying it both ways and seeing what's the most readable for that particular situation.

in terms of the generated code, they'll be exactly the same in most cases. occasionally there'll be an overload you can use in dot notation which makes it simpler than the query expression syntax, but value readability over everything else in most cases.

i also have a blog post on this topic. i would definitely recommend that developers should be comfortable with both options - i'd be quite concerned if a colleague were using linq but didn't understand the fundamentals of what query expressions were about, for example. (they don't need to know every translation involved, but some idea of what's going on will make their lives a lot easier.)

score:2

i always use the lambda syntax because to me it's clearer what's actually happening and it looks cool to boot. but we have some devs here that always do the opposite (sql nerds i guess :) fortunately, tools like resharper can just transform between the two with a click.


Related Query

More Query from same tag