NHibernate3查询VS QueryOver [英] NHibernate3 Query vs QueryOver
问题描述
我注意到有两种方法可以创建NHibernate的漂亮的通用友好访问
I noticed there are two ways to create nice generic friendly access to nhibernate.
IQueryOver<T, T> query= session.QueryOver<T>().Where(criteria);
和
IQueryable<T> query= session.Query<T>().Where(criteria);
每个接口的实现。
IQueryOver<TRoot, TSubType> : IQueryOver<TRoot>, IQueryOver
和
IQueryable<out T> : IEnumerable<T>, IQueryable, IEnumerable
的IQueryable实现IEnumerable,从而支持所有LINQ友好的事情你期望的那样。我趋向于这种实现,但想知道是否有人知道QueryOver的目的是,你不能查询完成?
IQueryable implements IEnumerable, thus supports all the LINQ friendly things you would expect. I am tending towards this implementation, but was wondering if anyone knew what the purpose of QueryOver was that you cannot accomplish with Query?
推荐答案
QueryOver
结合扩展方法和lambda表达式:
QueryOver
combines extension methods and lambda expressions:
IList<Cat> cats =
session.QueryOver<Cat>()
.Where(c => c.Name == "Max")
.List();
QueryOver
是一个强类型查询技术建立在NHibernate的标准API之上。
QueryOver
is a strongly-typed querying technology built on top of NHibernate’s Criteria API.
You can read more info here and here.
据我所知在LINQ提供的一些功能还没有实现。结果
我会使用 QueryOver 。code>结果
它可以让你编写优雅的代码,它是全功能的
As far as I know some features in the linq provider are not implemented yet.
I would use QueryOver
.
It allows you to write elegant code and it is fully featured.
一些值得的阅读。
这篇关于NHibernate3查询VS QueryOver的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!