Is there a way to specify a table to use for Hi-Lo values, with each entity having a per-row entry, via a convention (while still having nHibernate create the table structure for you)? I would like to replicate what Phil Haydon blogged about here, but without having to manually manage the table. As it stands, migrating his row-per-table code to its own convention will work only if you've already created the appropriate entries for 'TableKey' in the table already.
Alternatively, is this possible via the XML mappings?
And if all else fails, is the only other appropriate option to use a custom generator, a la this post?
For users of Fluent NHibernate, Anthony Dewhirst has posted a nice solution over here: http://www.anthonydewhirst.blogspot.co.uk/2012/02/fluent-nhibernate-solution-to-enable.html
Fabio Maulo talked about this in one of his mapping-by-code posts.
Mapping by code example:
For FluentNHibernate, you could do something like:
Also, Fabio explained how you could use
IAuxiliaryDatabaseObject
to create Hi-Lo script.You would use it like this:
Building off of Anthony Dewhirst's already excellent solution, I ended up with the following, which adds a couple improvements: