NHibernate.Linq - How well does it work?
Asked Answered
A

2

9

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!

Androus answered 25/3, 2011 at 19:20 Comment(0)
N
8

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.

Nihon answered 25/3, 2011 at 22:25 Comment(0)
H
9

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
Horsetail answered 25/3, 2011 at 22:20 Comment(0)
N
8

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.

Nihon answered 25/3, 2011 at 22:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.