Skip navigation

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.