score:7

Accepted answer

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.


Related Query

More Query from same tag