使用fluent nhibernate时如何设置配置属性? [英] How to set a configuration property when using fluent nhibernate?
本文介绍了使用fluent nhibernate时如何设置配置属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
尤其是我想设置current_session_context_class
.我知道如何在hibernate.cfg.xml中执行此操作,但是使用纯流利的配置完全可以吗?
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?
推荐答案
您可以在FluentConfiguration
实例上使用方法ExposeConfiguration
来访问原始的NHibernate Configuration
对象.
You can use the method ExposeConfiguration
on a FluentConfiguration
instance, to access the original NHibernate Configuration
object.
然后,您可以访问Properties
属性,并且可以添加current_session_context_class
一个.
Then, you'll have access to the Properties
property, and you will be able to add the current_session_context_class
one.
这是一个伪代码:
Fluently.Configure()
.Database(SQLiteConfiguration.Standard.InMemory)
.ExposeConfiguration(c =>
{
c.Properties.Add("current_session_context_class",
typeof(YourType).FullName);
})
//.AddMapping, etc.
.BuildSessionFactory();
这篇关于使用fluent nhibernate时如何设置配置属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文