Bringing Active Record and NHibernate Query Generator Together

time to read 2 min | 299 words

This time, I am going to try to do it without commentry. The next post is where all the fun will begin.

NHibernate Query Generator has been updated so it could work with Active Record as well. The way it works is simple, point it at an Active Record assembly, and it will spit out the generated query files. Usage:

NHibernate.Query.Generator <cs or vb> asssembly.dll <output-dir>

It supports generating C# or VB.Net code. I recommend adding this as a post-bulid step to your project:

"NHibernate.Query.Generator.exe" cs "$(TargetDir)$(TargetFileName)" "$(ProjectDir)\Queries"

This command will scan the generated assembly and generate the query files into the Queries directory. The unfortunate side affect means that after modifying your classes, you would need to recompile in order to get the new queries in place, but that is not a big hurdle, as far as I can see.

You can get the new version here (grab the 1.1 MSI). One word of advice, you need the NamedExpression and the ManyToOneNamedExpression files (since the generated code need them), which you can get at the respecive links. You would really want to do this, because they contain a very important update that I'll talk about in the next post...

Have fun...