Ayende @ Rahien

My name is Oren Eini
Founder of Hibernating Rhinos LTD and RavenDB.
You can reach me by phone or email:


+972 52-548-6969

, @ Q c

Posts: 6,130 | Comments: 45,556

filter by tags archive

NHibernate Linq 1.0 released!

time to read 2 min | 229 words

The most requested feature for NHibernate for the last few years has been Linq support, and it gives me great pleasure to announce the release of NHibernate Linq 1.0 RTM, which you can download from here.

NHibernate Linq support is based on the existing, proven in production, Linq provider in NHibernate Contrib. The plans to overhaul that and merge that into NHibernate’s proper for the next release are still active, but the project team feels most strongly that production quality Linq support is something that we ought to provide for our users now.

This Linq release support just about anything that you can do with the criteria API. We do not support group joins or subqueries in select clauses, since they aren’t supported by the criteria API. NHibernate’s Linq support has been tested (in production!) for the last couple of years, and most people find it more than sufficient for their needs.

We do plan for expanding the Linq support to support more, but the decision has been made that it makes absolutely no sense not to provide an interim, highly capable, release in the meantime for our users.

Enjoy, and happy linqing.

Oh, and I almost forgot, which would have been a shame. Many thanks for Tuna and Chad, for doing the bulk of the work on the provider.



Thanks for the great work. A LINQ provider for NHibernate is like a dream coming true. ;-)


Thank you - your efforts and everyone else's on this is extremely appreciated.

NHibernate has many ways to query and operate, it sets the bar.

You guys rock :)


I thunk group join and subqueries are very valuable. What is the roadmap for supporting that?

Pawel Pabich

Amazing, the last missing piece :)

Chris Cyvas

I got on Twitter to sing the praises of NHibernate and NHProf and found this awaiting me. What good karma! :) Congratulations to everyone!

Frans Bouma

"We do not support group joins or subqueries in select clauses, since they aren’t supported by the criteria API."

And no joins either (except the selectmany workaround). (might be a criteria limitation as well, dunno), as the Join method call isn't implemented. Also a lot of the groupby tests are commented out, dunno why that is though as the code seems to pick up group by (but I haven't checked yet whether it can do multiple aggregates onto a group by as you then have to fold subqueries into eachother).

Btw, what will you do when Steve is done with his code? You then have two linq providers... one is then dropped I presume?

Matteo Migliore

You are "simply the best"!!!!! Woww ;)


Congrats!!! Thank you all for your incredible work!!

Stefan Wenig

Since there are now two groups working on a LINQ provider, this would be a good moment to start involving each other in the planning.

Is there anything in the current LINQ provider that might not work with Steve's? Should there be some written warnings to users, or even stuff made obsolete or moved to another namespace, to prevent users from creating code that won't work with the new provider?

Or can it just be used freely? Will Steve or someone else take care of backwards compatibility?

BTW, the status of the new provider is:

  • Here at the re-motion project, we're basically done with the refactorings of re-linq.

  • Steve Strong just twittered that he'd be back on LINQ in a couple of weeks. Anybody who wants to see something emerge faster, I'd suggest you contact Steve and us. Personally, I don't see a reason why the authors of the current provider should not be able to help Steve creating the new one. Hey, you've been there, you'll love the simplicity of re-linq and the HQL AST compared to IQueryable and the Criteria API.

  • Once work on the provider starts, we expect results to show very quickly, at least that's what our own spikes indicate.

Steve Strong

Good job! it's great to see the NHContrib provider move to be an official release.

Stefan, there are no changes to the current plans - the provider that has just been released has been around for a while and I regularly speak with the authors. It's based on the Criteria API and as such is limited by how far it can ever go. The new AST based provider is still very much in plan. We'll aim for a degree of backwards compatibility, but I think will live with a couple of breaking changes if we can justify the benefits.

Stefan Wenig

Steve, I was not concerned about the plan for the new provider, but releasing the current one (and promoting it on the official NH blog and here) sends a message. So compatibility becomes a concern, and I think this should be adressed in the announcements. Good to hear that you're already in contact about that!


now we just need some extensive blog posts tutorials :) (hint hint.. :P )

(and don't forget the newbie's who have never used NHibernate before but would be interested, now that there's Linq-to-NHibernate) :)


Thanks guys for putting all this together..

Just tried it, apparetly String.ToLower() is still unimplemented. Can I make suggestion for that feature?

At the moment, how do you express non-case-sensitive String.Contains()? I believe it's a very common requirement, but apparently this doesn't work with NH-Linq:


Is there anyway to express this in current state of NH-Linq?



Excellent, now even less reason to use entity framework.


So am I the only one that is getting corrupt zip file messages when trying to download the 2.1.0 NHibernate binary file required to use this LINQ provider?

Ayende Rahien


looks like, can you try in a different browser?


Sweet! Will this work with Fluent NHibernate out of the box?


Is this just for NH 2.1 or will it work with 2.0, being ICriteria based and all...?


This is fantastic news, maybe I can finally convince my software architect's to ditch EF and move to nHibernate!!

Michael Johnson

Very cool! I will definitely use this.


Nice, will have to give this a try



Ask your software architect why he didn't design a swappable repository layer so it doesn't matter if you use EF or NH... not hard to do, just takes a lot of discipline...

See what he says :) (or duck quickly !)

Ayende Rahien


It doesn't work.

I just tried is on a very small app (NerdDinner), and it doesn't work even there.

OR/M are not interchangable.

Max Pool

This is epic - congrats everyone on a job well done.


Great! Great!

Alex Yakunin

Hello Ayende,

We've made some preliminary comparisons related to LINQ and NHibernate performance. For now we're comparing it just with DO4, but later more comprehensive results will appear.

Anyway, current results aren't very optimistic: blog.dataobjects.net/.../...rmance-comparison.html

The question is: can we contact you to help us with making our NHibernate-related tests fully honest? I mean probably we missed some option we must turn on or off, etc.? We expect we'll be able to share the results (source code, etc.) by the end of the next week.

Concerning LINQ: well, it's released, but I think it would be more honestly to call this as CTP or something like this. ~ 75% of our tests fail for LINQ features fail on NH. My impression is that only very basic stuff like Where works. What about Join, GroupJoin, SelectMany, First/Single in subqueries, etc.?

Ayende Rahien


In general, I don't like benchmarks:

Mostly because there are a lot of hidden assumptions that are going to bite you when you do things with them.

You can send me the code and I'll review it, yes.

About Linq. It is RTM because we have seen people use it in production for years.

I am not surprised that a lot of the tests fail, tests tend to try to find the edge cases. This is not what this release it about. It is about providing a linq provider that can solve a large amount of the day to day stuff that people are using.

We are planning of writing a full featured linq provider, but that would be for the next version, and use a different approach.

Alex Yakunin

Thanks - we'll do this. Concerning hidden assumptions:

  • Tests must run in identical conditions. If this is not possible, all the differences must be described explicitly (that's why I need your help).

  • The measured cases must expose some real-life scenarios. E.g. above test with proxies is obviously non-realistic. I can't imagine application constantly generating proxies without re-using them - it's really the way to get OutOfMemoryException.

  • In general, I dislike overall or weighted scores for test sequences. A lot depends on which features are chosen to be scored and their scale numbers here, so it's better to simply show all the particular results and allow users to choose what's more important for them by their own way.

If these conditions are satisfied, I believe in tests ;) Obviously, real-life application results can differ, but complete contrast to tests is rare. So at least, tests show you what you might expect / what must be tuned up.


Can the Linq provider be used with Second Level Cache?


Ayende Rahien

It could, but that is not exposed currently

John Simons

Is there going to be a mono version?

Ayende Rahien


I have no idea, but it should


I am using Active record which implements linq to nhibernate.

It is working perfectly.

The only thing is I can't find an 'Like' operator.

Can you tell me how to perform a 'like' clause.


can i use with .net 2.0 ? or have to install .net 3.5


@Laurens: Did you try myString.Contains("blabla")?

This should work without problems.


Great, I will definitely use it too!


Yeah,Thanks,My from China.

Comment preview

Comments have been closed on this topic.


  1. How to waste CPU and kill your disk by scaling 100 million inefficiently - one day from now
  2. RavenDB Conference 2016–Slides - about one day from now

There are posts all the way to Jun 01, 2016


  1. The design of RavenDB 4.0 (14):
    26 May 2016 - The client side
  2. RavenDB 3.5 whirl wind tour (14):
    25 May 2016 - Got anything to declare, ya smuggler?
  3. Tasks for the new comer (2):
    15 Apr 2016 - Quartz.NET with RavenDB
  4. Code through the looking glass (5):
    18 Mar 2016 - And a linear search to rule them
  5. Find the bug (8):
    29 Feb 2016 - When you can't rely on your own identity
View all series


Main feed Feed Stats
Comments feed   Comments Feed Stats