How can I rewrite following so that I can do ObjectFactory.GetNamedInstance("MyNHConfiguration") at later time. "Configuration" is in the variable "cfg" under ExposeConfiguration lambda
ForRequestedType<ISessionFactory>()
.CacheBy(InstanceScope.Singleton)
.AddInstances(x => x.ConstructedBy(() =>
Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2005
.AdoNetBatchSize(10)
.Driver("NHibernate.Driver.SqlClientDriver")
.ProxyFactoryFactory("NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle")
.UseOuterJoin()
.ConnectionString(@"Server=.\SQLEXPRESS;User Id=xxcxcca;Password=password;Database=cccvddd;")
.ShowSql()
.CurrentSessionContext("thread_static")) // CHANGE THIS FOR WEB
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<MetaProject>())
.ExposeConfiguration(
cfg =>{
cfg.SetProperty(
Environment.TransactionStrategy,
typeof (AdoNetTransactionFactory).FullName);
cfg.SetProperty(Environment.GenerateStatistics, "true"); //REMOVE FOR LIVE
})
.BuildSessionFactory())
.WithName("MySessionFactory"));