Has anyone managed to do this?
Basically I am looking for the following:
<?xml version="1.0"?>
<configuration>
<facilities>
<facility id="nhibernate"
isWeb="false"
type="Castle.Facilities.NHibernateIntegration.NHibernateFacility, Castle.Facilities.NHibernateIntegration"
configurationBuilder="FS.SUV.Services.FluentNHibernateConfigBuilder, FS.SUV.Services">
<factory id="nhibernate.factory">
<settings>
<item key="show_sql">false</item>
<item key="connection.provider">NHibernate.Connection.DriverConnectionProvider</item>
<item key="connection.driver_class">NHibernate.Driver.SqlClientDriver</item>
<item key="dialect">NHibernate.Dialect.MsSql2008Dialect</item>
<item key="connection.connection_string_name">DBConnection</item>
<item key="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory , NHibernate.ByteCode.Castle</item>
</settings>
</factory>
</facility>
</facilities>
</configuration>
And the corresponding code to install this would be
container
.Install(Castle.Windsor.Installer.Configuration.FromXmlFile("Windsor.config"))
Where Windsor.config is the xml above.
In a fluent form
Typyically you can do stuff like
.AddFacility<NHibernateFacility>("NHibernate", cfg=>cfg.FacilityConfig)
However from the options in Intellisense it is unclear if anything will provide what I want from the xml snippet above.
I have done some searches which have returned the following which either do not work or refer to a previous version. I am using NHibernate 2 for this one project with Castle.
But with no joy. Can anyone help! I know, I know I could always use a different IOC! But I am curious if anyone else has come across this issue. I can also just leave it as xml but I prefer the fluent configuration because I can then dynamically set connections strings and other factory properties at will.
Any help will be most appreciated.
Yes, there's a fluent NHibernate Facility at https://github.com/haf/Castle.Facilities.NHibernate.
You configure it using FluentNHibernate and then you can have session-per-transaction, session-per-web request or session-transient lifestyles.