Geo*_*uer 5 .net nhibernate fluent-nhibernate
让我们首先解决这个问题:我知道SessionFactory是不可变的 - 我正在尝试在运行时更改配置并重新生成ISessionFactory.
具体来说,我有一个Customer映射,它将在运行时将一些字段添加到其动态组件节点.我想做这样的事情
var newSessionFactory = previousConfiguration
.RemoveClassMapping(typeof(Customer))
.AddXmlString(newMappingForCustomer)
.BuildSessionFactory();
Run Code Online (Sandbox Code Playgroud)
但是,我没有看到任何明显的方法来删除映射,有什么我可以做的不能重新生成整个配置?
这是不可能的。您必须重新生成Configuration.
我最初的建议是为您的模型选择不同的策略。
但是,如果您决定这样做:-),您可以:
Configuration(不包括Customer)MemoryStreamCustomer如果需要,添加“基本”映射SessionFactoryCustomerConfigurationCustomer映射并创建最终的SessionFactory