简体   繁体   English

NHibernate.Linq - 它的效果如何?

[英]NHibernate.Linq - How well does it work?

we're starting a new project using NHibernate, and considering using NHibernate.Linq (The embedded version in 3.0, not the contrib project). 我们正在使用NHibernate开始一个新项目,并考虑使用NHibernate.Linq(3.0中的嵌入式版本,而不是contrib项目)。 I'm aware that this is a relatively recent addition. 我知道这是一个相对较新的补充。 Has anyone used the current LINQ for NHibernate much? 有没有人使用当前的LINQ for NHibernate? Is it mature enough for real-world applications yet? 它对于真实世界的应用程序是否足够成熟?

Specificly, have you encountered difficult bugs, how is the performance, and are there any major gaps in support that caused you problems? 具体而言,您是否遇到过困难,性能如何,是否存在导致您出现问题的支持方面的任何重大差距?

Thanks! 谢谢!

I've used NHibernate LINQ extensively in my current project, and I have some mixed feelings about it: 我在当前项目中广泛使用了NHibernate LINQ,我对它有一些复杂的感受:

Having used the former LINQ in the NH Contrib project in NH2.1, I can tell you that this new version is much more mature, and suitable for most real-world scenarios. 在NH2.1的NH Contrib项目中使用了前LINQ后,我可以告诉你这个新版本更加成熟,适合大多数现实场景。 But, and as soon as you start to do more complex queries, and/or need to be especially carefull with performance, some road blocks start to appear. 但是,一旦你开始做更复杂的查询,和/或需要特别注意性能,一些路障就会开始出现。 It still has some bugs, and you'll see the infamous "Method Not implemented" a lot. 它仍然有一些错误,你会看到臭名昭着的“方法未实施”很多。 Regardless, it is ORM agnostic, and allows some nice separation of concerns and you'll leverage your existing LINQ knowledge. 无论如何,它与ORM无关,并且可以很好地分离关注点,并且您将利用现有的LINQ知识。 It works pretty well... 它工作得很好......

So, my sugestion is: IMHO, it is ready for real-world applications, but don't expect it to be the silver-bullet that solves every problem, and be prepared to use QueryOver/Criteria/HQL in some (or many) places. 所以,我的消息是:恕我直言,它已经为现实世界的应用程序做好了准备,但不要指望它是解决每个问题的银弹,并准备在某些(或许多)中使用QueryOver / Criteria / HQL地方。

Just some side-notes on features that not work very well (from my experience): 关于功能不太好的一些侧面说明(根据我的经验):

  • the "Any" method “任何”方法
  • the "Fetch" method “获取”方法
  • second level cache 二级缓存
  • futures 期货
  • spatial extensions 空间扩展

NHibernate Linq is a promising feature with lots of potential. NHibernate Linq是一个很有潜力的有前途的功能。 Unfortunately I have already encountered several situations where a query in Linq did not work and I had to use QueryOver (another very fine addition). 不幸的是,我已经遇到过几种情况,Linq中的查询不起作用,我不得不使用QueryOver(另一个非常精细的添加)。

Is it mature enough for real-world applications? 它是否足以成为现实世界的应用程序? Yes, if you are not limiting yourself to only using Linq and nothing else (HQL, ICriteria, QueryOver, or even pure SQL). 是的,如果您不仅限于使用Linq而不是其他任何东西(HQL,ICriteria,QueryOver,甚至是纯SQL)。

Here is a nice, short list of examples comparing the different APIs . 以下是比较不同API的一个很好的简短示例列表。

The question came up in a slightly different form: Tradeoffs using NHibernate 3.0 QueryOver or LINQ provider 问题的形式略有不同: 使用NHibernate 3.0 QueryOver或LINQ提供程序进行权衡

I use it in combination with WCF RIA Services where the return types for methods is IQueryable. 我将它与WCF RIA Services结合使用,其中方法的返回类型是IQueryable。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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