In particular, I'd like to set current_session_context_class
. I know how to do it in hibernate.cfg.xml, but is it possible at all with pure fluent configuration?
Asked
Active
Viewed 1,941 times
6

Sergey Aldoukhov
- 22,316
- 18
- 72
- 99
1 Answers
8
You can use the method ExposeConfiguration
on a FluentConfiguration
instance, to access the original NHibernate Configuration
object.
Then, you'll have access to the Properties
property, and you will be able to add the current_session_context_class
one.
Here is a the pseudo-code:
Fluently.Configure()
.Database(SQLiteConfiguration.Standard.InMemory)
.ExposeConfiguration(c =>
{
c.Properties.Add("current_session_context_class",
typeof(YourType).FullName);
})
//.AddMapping, etc.
.BuildSessionFactory();

Romain Verdier
- 12,833
- 7
- 57
- 77
-
This doesn't work for me, when I call GetCurrentSession it still throws an exception telling me to set the property. – BenCr May 06 '11 at 16:08
-
Well, my answer is 2 years old now, so it doesn't surprise me that much. Unfortunately, I'm no longer using FluentNHibernate and I'm not sure I can update my answer anytime soon... – Romain Verdier May 09 '11 at 07:30
-
Unfortunately, does not work for me either, I'm having a similar problem with FlushMode, see https://stackoverflow.com/questions/52260763/nhibernate-fluently-configure-default-flush-mode-for-session-sessionfactory/52289646#52289646 – ironstone13 Sep 12 '18 at 08:54