score:8
No, the
Select
is not necesssary if you are not actually transforming the returned type.In this case, the ordering of the method calls could have an impact on performance. Sorting all the objects before filtering is sure to take longer than filtering and then sorting a smaller data set.
score:5
The .Select is unnecessary in this case because .Cast already guarantees that you're working with IEnumerable<string>.
The ordering of .OrderBy and .Where doesn't affect the results of the query, but in general if you use .Where first you'll get better performance because there will be fewer elements to sort.
Source: stackoverflow.com
Related Articles
- LINQ query to perform a projection, skipping or wrapping exceptions where source throws on IEnumerable.GetNext()
- Simple SELECT WHERE LINQ Query to a list
- ordering of OrderBy, Where, Select in the Linq query
- How do I apply OrderBy to a Linq Query for a select list
- How to put where condition in select condition in Linq query
- Replace OrderBy with Where in LINQ query
- How to Select top (5) contributors group by Business type code in c# linq query
- How can I do a LINQ query joining two entities and select what a Where on one of the entities?
- How to write aggregate query in LINQ reusing part of the select code
- Orderby after Select at LINQ query
- Add WHERE clause to every LINQ Select query
- Linq query to select rows where a column is a max value
- Using a Linq query to select objects where any value of a property matches values from a list
- LINQ query to conditionally filter on a where clause and select the values from another table
- Select the Value of custom OrderBy in Linq Query
- write linq similiar where in select from with inner join in sql query
- use linq to group by and then run select query with where condition
- C# - if condition in Linq select query with where clause
- LINQ Select Query with Where Condition Which returns single record
- How do I create a linq query where the select column name is a variable
- Where clause in complex linq query giving the following error "A query body must end with a select clause or a group clause linq"
- C# Linq query to select top result where a condition is satisfied
- Linq Query Select from table1 where id in (select from table2 inner join table3 on table2 = table3 where table3 = id )
- select in where - Linq Query
- LINQ Orderby Descending Query
- LINQ query to select top five
- Linq select objects in list where exists IN (A,B,C)
- Linq code to select one item
- How to Select Min and Max date values in Linq Query
- Can I select multiple objects in a Linq query
- How to assign values to any one or two prop using linq c# or inside generic method?
- EF DbContext on a generic repository does not perform the expected includes when transforming the data into a list
- How do I pass a parameter from the select list into a function for joining a linq query?
- How to Read value of any node element from XML formatted string?
- Trying to follow the example for ToTraceString(), but it fails. Why?
- iterating through a changing list with Linq
- Dynamic list of button with events from xml
- enumerated more than once in linq to sql stored procedure call
- How do I SKIP the already iterated rows but read the next rows that are not being iterated?
- How can filtering be possible without for loop using LINQ?
- Linq to sql left join additional null check needed
- Replace XML-element with LINQ to XML
- Using linq group by to get from a list of objects with a DateTime property to a list with an interval StartDate, EndDate
- c# Dictionary of group perfomance
- C# MongoDB Driver 2.15.0 unable to execute In Query with Linq
- Sorting IQueryable by Aggregate in VB.net
- How to convert IEnumerable<CustomType> to List, applying grouping logic, and convert back to IEnumerable<CustomType>?
- Linq Group By statement on a Dictionary containing a list
- how to sort list with strings containing numbers?
- type ObjectQuery or DbQuery Error when updating a object