Ayende @ Rahien

Unnatural acts on source code

NHibernate Query Generator - Collection querying

In the repository (Exists / NotExists):

   1:  [Test]
   2:  public void CanQueryOverCollections()
   3:  {
   4:      User one = User.FindOne(Where.User.Blogs.Exists(
   5:                                  Where.Blog.Name == "Ayende @ Blog"
   6:                                  ));
   7:      Assert.IsNotNull(one);
   8:  }
 
Will result in:
 
   1:  SELECT this_.Id as Id4_0_, this_.Name as Name4_0_, this_.Email as Email4_0_ 
   2:  FROM Users this_ WHERE exists (SELECT this_0_.Id as y0_ FROM Blogs 
   3:  this_0_ WHERE this_0_.Name = @p0)

 

Fluent interfaces? Take that.

Comments

Sean Chambers
06/05/2007 04:05 AM by
Sean Chambers

I toyed around with fluent interfaces recently but found that it made the methods too confusing to follow like Martin states in his bliki, and take a little more time to plan out.

Do you see any real benefit when using fluent interfaces with a very small team? 1-2 people?

Ayende Rahien
06/05/2007 04:33 AM by
Ayende Rahien

Look at the query above and tell me if it isn't very clear what is going on around there?

I certainly think so

ernst naezer
06/05/2007 07:53 AM by
ernst naezer

I don't think the team size has very much to do with it. These tools help you read the code when making changes after 4 months of working on a different project :)

Jericho
06/05/2007 09:37 AM by
Jericho

It`s cool!! But where can I get simple quickstart and some examples for NQG ? Can you help me with this, please?

Ayende Rahien
06/05/2007 10:32 AM by
Ayende Rahien

I will try to post something about it soon.

Sander Rijken
06/06/2007 11:47 AM by
Sander Rijken

Looks very useful indeed.

Is the "Where" class available, and if so in what assembly? I tried locating it in my current MonoRail/ActiveRecord.NET/NHibernate set of assemblies, but couldn't find it.

Ayende Rahien
06/06/2007 12:19 PM by
Ayende Rahien

Sander,

It is a class that is generated by NHQG

Nick
08/03/2007 05:15 AM by
Nick

I'm sorry to post this here since it might be a bit off topic, but I can't seem to get NHQG working as a VS custom tool. I have put NHibernateQueryGenerator as the Custom Tool in my hbm's properties and it creates a foo.hbm.cs file. However, the file doesn't seem to ever get updated. I can't figure out what I'm missing though. I'm using NHQG 1.9.

Also, is there a way to get it to recurse through directories if running cmd line? I've tried */.hbm.xml, but get an error.

Ayende Rahien
08/03/2007 06:16 AM by
Ayende Rahien

Nick, because of the issues in getting the custom tool to work, I am not keeping track of it anymore. It certainly should work, if you put the right registry entries, but the complexity and constant updating just didn't make it worthwhile for me.

About the second, there isn't a way to do it right now, feel free to send a patch.

Nick
08/03/2007 03:43 PM by
Nick

Thanks. It was the registry issue.

Comments have been closed on this topic.