NHibernate Linq Provider question
Can anyone answer me what are th开发者_开发知识库e differences of
Session.Query
Session.Linq and Session.QueryOverWhat I'm really interested in:
What would be supported in the future versions. What should I start to use in a clean project.Please tell me your thoughts about these three...
Thanks, Zoltán
Session.Query is the class to use when you want to use the new and much improved linq provider in NHibernate 3.0. If you are using linq and you are starting a new project, this is the class to use.
Session.Linq is the class to use if you what to use the old linq provider. I would say that you would only be using this class with older code bases. The older linq provider is really a wrapper around the Criteria API and, while fine for simpler queries, it is known to have limits once things get more demanding.
Session.QueryOver is a wrapper around the Criteria API of NHibernate. If you are already well versed in the Criteria API, this is a very approachable interface. It eliminates most of the strings, replacing them with lambda expressions. It is a very fluent interface. The syntax is linq-like but this is not a linq provider.
At this point in time I would say you would want to be using the Query and the QueryOver interfaces.
精彩评论