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!
NHibernate is a port of Hibernate from Java, one of the oldest and most respected Object-Relational Mappers (ORMs).
LINQ (Language Integrated Query) is uniform query syntax in C# and VB.NET to retrieve data from different sources and formats. It is integrated in C# or VB, thereby eliminating the mismatch between programming languages and databases, as well as providing a single querying interface for different types of data sources.
NHibernate is a mature, open source object-relational mapper for the . NET framework. It's actively developed, fully featured and used in thousands of successful projects. Easily map regular C# or VB.NET object models designed in Visual Studio.
A fetching strategy is the strategy NHibernate will use for retrieving associated objects if the application needs to navigate the association. Fetch strategies may be declared in the O/R mapping metadata, or overridden by a particular HQL or Criteria query.
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):
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With