How to set configuration property when using free nhibernate?

In particular, I would like to install current_session_context_class. I know how to do this in hibernate.cfg.xml, but is this even possible with a clean, smooth configuration?

+5
source share
1 answer

You can use the ExposeConfigurationinstance method to FluentConfigurationaccess the source NHibernate object Configuration.

Then you get access to the property Properties, and you can add current_session_context_classone.

Here is the pseudo code:

Fluently.Configure()
   .Database(SQLiteConfiguration.Standard.InMemory)
   .ExposeConfiguration(c =>
                        {
                          c.Properties.Add("current_session_context_class", 
                                           typeof(YourType).FullName);
                        })
   //.AddMapping, etc.
   .BuildSessionFactory();
+7
source

All Articles