Ayende @ Rahien

Refunds available at head office

NHibernate Linq 1.0 released!

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.

Comments

Iain Holder
07/26/2009 11:04 AM by
Iain Holder

Ace! Congrats Oren.

Frank
07/26/2009 11:43 AM by
Frank

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

Ugo Lattanzi
07/26/2009 01:05 PM by
Ugo Lattanzi

Yeahhhhhhhhhh, Thx guys

Steve
07/26/2009 02:11 PM by
Steve

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

-
07/26/2009 02:11 PM by
-

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

Pawel Pabich
07/26/2009 02:37 PM by
Pawel Pabich

Amazing, the last missing piece :)

Chris Cyvas
07/26/2009 03:01 PM by
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
07/26/2009 04:15 PM by
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
07/26/2009 06:29 PM by
Matteo Migliore

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

Roberto
07/26/2009 06:44 PM by
Roberto

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

Stefan Wenig
07/26/2009 07:24 PM by
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
07/26/2009 08:46 PM by
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
07/26/2009 09:32 PM by
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!

PK
07/26/2009 11:11 PM by
PK

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

Bob
07/27/2009 07:20 AM by
Bob

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:

blog.Title.ToLower().Contains(title.ToLower());

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

Thanks...

imran
07/27/2009 12:58 PM by
imran

Excellent, now even less reason to use entity framework.

pb
07/27/2009 01:57 PM by
pb

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
07/27/2009 01:59 PM by
Ayende Rahien

pb,

looks like, can you try in a different browser?

mgroves
07/27/2009 02:31 PM by
mgroves

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

John
07/27/2009 02:40 PM by
John

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

Matt
07/27/2009 06:33 PM by
Matt

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

Michael Johnson
07/27/2009 07:00 PM by
Michael Johnson

Very cool! I will definitely use this.

SQLDenis
07/27/2009 07:14 PM by
SQLDenis

Nice, will have to give this a try

Graham
07/27/2009 08:17 PM by
Graham

Matt,

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
07/27/2009 09:28 PM by
Ayende Rahien

Graham,

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
07/28/2009 04:41 AM by
Max Pool

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

Lê Hoàng Dũng
07/28/2009 08:37 AM by
Lê Hoàng Dũng

Thanks Ayende Rhien! NHibernate.LinQ make NHibernate tronger than ever.

Kwon
07/29/2009 07:05 AM by
Kwon

Great! Great!

Alex Yakunin
07/29/2009 03:04 PM by
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
07/29/2009 03:12 PM by
Ayende Rahien

Hi,

In general, I don't like benchmarks:

ayende.com/.../Trusting-the-benchmark.aspx
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
07/29/2009 04:22 PM by
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.

Roberto
08/01/2009 02:16 AM by
Roberto

Can the Linq provider be used with Second Level Cache?

Roberto.-

Ayende Rahien
08/01/2009 06:34 AM by
Ayende Rahien

It could, but that is not exposed currently

John Simons
08/02/2009 01:38 AM by
John Simons

Is there going to be a mono version?

Ayende Rahien
08/02/2009 07:20 PM by
Ayende Rahien

John,

I have no idea, but it should

Laurens
08/05/2009 12:12 PM by
Laurens

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.

kindy.pham
08/09/2009 04:57 PM by
kindy.pham

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

Icey
08/13/2009 03:02 PM by
Icey

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

This should work without problems.

Tiendq
08/25/2009 06:08 AM by
Tiendq

Great, I will definitely use it too!

Jacky
09/08/2009 09:30 AM by
Jacky

Yeah,Thanks,My from China.

Comments have been closed on this topic.