Well it is nothing super creative, but it took me a while to do that.
And so you have probably two possible solutions: write your own implementation of IConfiguratorProvider, or as I did configure the default one:
var nhConfigurator = new DefaultSessionFactoryConfigurationProvider();
nhConfigurator.AfterConfigure += nhConfigurator_AfterConfigure;
var sfp = new SessionFactoryProvider(nhConfigurator);
container.Register(Component
.For<ISessionFactoryProvider>()
.Named("sessionFactoryProvider")
.Instance(sfp));
static void nhConfigurator_AfterConfigure(object sender, ConfigurationEventArgs e)
{
NHConfigurationBuilder.AddMappingAssembliesTo(e.Configuration, new string[] { "XXXX.Dal.dll" });
}
And that’s it. The ConfigurationEventArgs expose configuration object as you can see. That event could also be used to export db schema, as it is done in uNHaddins examples.
Additionally I’ve found useful information in Gustavo Ringel blog. And of course in HunabKu blog.
Advertisement