score:7
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.
Source: stackoverflow.com
Related Query
- Is the from keyword preferable to direct method calls in C#?
- Code equivalent to the 'let' keyword in chained LINQ extension method calls
- Enumerable.Empty<T>().AsQueryable(); This method supports the LINQ to Entities infrastructure and is not intended to be used directly from your code
- Why do asynchronous calls in C# need to be declared as such if the method they reside in is declared with the 'async' keyword already?
- Can someone tell me why this simple bit of c# code won't work, involves recursively calling method from within itself to get the root category ID
- Why can't I call an extension method from a base class of the extended type?
- Generating the Shortest Regex Dynamically from a source List of Strings
- How to understand the following C# linq code of implementing the algorithm to return all combinations of k elements from n
- linq extension method to take elements from the end of the sequence
- Return Count from Netflix oData Service When the LINQ Count() Method Doesn't Work
- How does linq actually execute the code to retrieve data from the data source?
- Removing a single item from an enumerable source when the items are equal
- The given value of type String from the data source cannot be converted to type int of the specified target column
- The type arguments for method GroupJoin cannot be inferred from the usage
- How to apply the SQL in keyword in Entity Framework method syntax?
- creating Linq to sqlite dbml from DbLinq source code
- The type arguments for method cannot be inferred from the usage. Try specifying the type arguments explicitly
- If I expose IQueryable from my service layer, wouldn't the database calls be less if I need to grab information from multiple services?
- Proper way to convert results from the Skip LINQ method
- Is this the code the compiler generates from the following query expression?
- How can I check the number of calls to the database in LINQ query when using .NET Core and Code First?
- The type '' cannot be used as type parameter 'T' in the generic type or method ''. There is no implicit reference conversion from '' to ''
- Can I get values from my database using this method but without generating the additional text?
- Generic lists: The type arguments for method cannot be inferred from the usage in lambdas
- Why the extension method of where for LINQ in this code would print out a single number while it shouldn't print anything at all?
- Why isn't the IEnumerable returned from LINQ Where() method wholly consumed by Count()?
- The type arguments for method '' cannot be inferred from the usage. Try specifying the type arguments explicitly
- Linq code to get the index of an object in an array from an object within a list
- C# exclude duplicate code from two method returning expression
- data type(s) of the type parameters ) in method cannot be inferred from these arguments
More Query from same tag
- How can I traverse this list in this manner?
- CRM SDK - Is Linq slower than QueryExpression?
- How to use group by in rows?
- LINQ to match substring from another list
- Problem understanding Linq query structure when involves filtering, flattening and grouping
- Issue with LINQ
- Create a String[] between the range of year
- LINQ to SQL *compiled* queries and when they execute
- How can I get the nested rows ordered by nesting level?
- ASP.NET Web API return queryable DTOs?
- Convert Session Object to IOrderedQueryable<T>
- MonoTouch & LINQ - Operation is not valid due to the current state of the object
- Select only attributes of parent element
- LINQ to Entity query execution time
- Get a random item from a collection that does not already exist in another collection - LINQ?
- How to use descending with ascending in linq?
- How to convert the foreach loop to linq
- Improving performance of Linq to SQL list intersection
- Count users where subscription end within month Linq c#
- Remove duplicate rows of a datatable based on a list of key fields
- How to pass an Expression into a LINQ query?
- Compare dd-mm-yyyy datetime
- LINQ query not returning the correct result
- Why does this combination of Select, Where and GroupBy cause an exception?
- Cannot insert the value NULL into column ... Exception issues
- Cannot assign void to an implicitly-typed local variable
- get last element with linq to sql
- record not updating - Linq SQLite
- Filter tree list retaining parent using LINQ
- How to set conditional filter in where clause using linq?