开发者

NHibernate.Linq - How well does it work?

开发者 https://www.devze.com 2023-02-19 15:32 出处:网络
we\'re starting a new project using NHibernate, and considering using NHibernate.Linq (The embedded version in 3.0, not the contrib project). I\'m aware that this is a relatively recent addition. Has

we're starting a new project using NHibernate, and considering using NHibernate.Linq (The embedded version in 3.0, not the contrib project). I'm aware that this is a relatively recent addition. Has anyone used the current LINQ for NHibernate much? 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:

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. 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. 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.

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. 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).

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).

Here is a nice, short list of examples comparing the different APIs.

The question came up in a slightly different form: Tradeoffs using NHibernate 3.0 QueryOver or LINQ provider

I use it in combination with WCF RIA Services where the return types for methods is IQueryable.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号