简体   繁体   中英

Is there an overview for Nhibernate in which order you must use extension methods?

Is there somewhere an overview where is displayed or explained in which order Linq methods must be called?

For example, you'll get an exception if you first call Take(200) and then OrderBy(..) . But you won't get an exception when you switch those calls.

So my question is, does someone know some documentation where this is explained? Or knows a place where this kind of information is listed?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM