Accepted answer

The reason you can't call Take(200) before calling OrderBy is that Take(200) forces the NHibernate LINQ provider to evaluate the linq query. Once the query has been evaluated, it cannot add further SQL clauses to the mix without re-evaluating the query, something that might have unintended consequences.


There is no restriction on what order they can be called in. It's perfectly valid to call Take(200) followed by OrderBy in LINQ. LINQ is nothing more than a series of methods; it doesn't describe how those methods are actually implemented. Some of the actual implementations include Linq-to-objects (a bit of a special case), LINQ-To-SQL, Entity Framework, and then any number of other query providers based on the IQueryable LINQ methods.

Some particular providers may only support a subset of the LINQ methods, or may not support some other aspect that LINQ can describe. In those cases they may error out (or do some other undesirable behavior). You will need to look into the documentation of whatever specific LINQ provider you are using to see what it does and does not support.

Related Query

More Query from same tag