score:7
does
mylist.orderby(x => x.prop1)
return the filtered list
no. linq methods (at least typically) return queries, not the results of executing those queries.
orderby
just returns an object which, when you ask it for an item, will return the first item in the collection given a particular ordering. but until you actually ask it for a result it's not doing anything.
note you can also get a decent idea as to what's going on by just looking at what orderby
returns. it returns iorderedenumerable<t>
. that interface has a method createorderedenumerable
which:
performs a subsequent ordering on the elements of an iorderedenumerable according to a key.
that method is what thenby
uses to indicate that there is a subsequent ordering.
this means that you're building up all of the comparers that you want to be used, from the orderby
and all thenby
calls before you ever need to generate a single item in the result set.
for more specifics on exactly how you can go about creating this behavior, see jon skeet's blog series on the subject.
Source: stackoverflow.com
Related Query
- Does LINQ know how to optimize "queries"?
- How do I know what does EF translate Linq queries into?
- If it's bad to use inline SQL, how does using LINQ to perform queries differ in practice?
- How does a LINQ expression know that Where() comes before Select()?
- How does linq actually execute the code to retrieve data from the data source?
- How does this linq code that splits a sequence work?
- Does anyone know how to reproduce an NVL() function in linq
- Does LINQ convert code to SQL queries
- How does Linq know the name of an element?
- Does anyone know how to translate LINQ Expression to NHibernate HQL statement?
- Suggestions on how to optimize code for ordering by string in linq
- How does the following LINQ statement work?
- How does LINQPad reference other classes, e.g. Books in the LINQ in Action samples
- How are people unit testing code that uses Linq to SQL
- What does this C# code with an "arrow" mean and how is it called?
- C# LINQ Orderby - How does true/false affect orderby?
- How does LINQ expression syntax work with Include() for eager loading
- How does LINQ Except work?
- How does deferred LINQ query execution actually work?
- Why does C# compiler create private DisplayClass when using LINQ method Any() and how can I avoid it?
- how to know if my linq query returns null
- How does LINQ .distinct method sort?
- How much overhead does 'Update Check' have for LINQ UPDATES
- how does except method work in linq
- How does Linq work (behind the scenes)?
- How does LINQ defer execution when in a using statement
- How does the LINQ RefreshMode work?
- How does linq Last() determine the last item?
- How can I directly execute SQL queries in linq
- LINQ to XML - How does it work?
More Query from same tag
- Execute linq expression
- Query a parent-children entities with one-many relationships and retrieve children records based on values in the parent record using LINQ to Entities
- What am I missing in this chain of predicates?
- Time Stamp in DBML is solving concurrency issues...why?
- Will LINQ use specialized/optimized versions of functions based on the type of the input?
- How and I introduce an "or" operator into a linq query join
- How can I add more than 2 conditions to the LlNQ where clause?
- Printing some data
- Iterative loop to query the most occurring field
- Getting Xelement.elements() using a path
- C# LINQ: How is string("[1, 2, 3]") parsed as an array?
- Remove items in one IList<> from another IList<>
- join not returning all elements in left table C# lambda
- How to Get Set Linq Entity With Only String Name
- Object reference not set to an instance of an object. Exception while sending data yo View through viewmodel
- Linq to XML Remove multiple returns
- how to return back list of data from controller to knockout function to view page
- sum for nullable field in linq
- How to convert two columns into a single string column with dynamic linq?
- C# Automapper IQueryable - LINQ 2 SQLite - Query returns only parent, nested child always null
- Using PredicateBuilder is there a way to build a predicate off of a variable length list of field names?
- LINQ One to Many, 3 levels Deep Question
- Cast<> for hierarchical data structure
- How can I produce a join on a substring and an integer in Entity Framework?
- Extract key value from a string Using Linq
- How can I select from a collection with LINQ?
- C# - Nested LINQ queries
- How to use LINQ remove a subset of list with certain criteria?
- Linq Where Clause - Accessing a tables column name
- C# Linq generic search