NHibernate:如何在所有实体上设置DynamicUpdate? [英] NHibernate: How to set DynamicUpdate on all Entities?

查看:160
本文介绍了NHibernate:如何在所有实体上设置DynamicUpdate?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在所有实体上设置DynamicUpdate和DynamicInsert?



当我将其与我的映射代码放在一起时,它的工作原理非常完美,但是我想指定它只有一次为我的整个项目。

我创建会话或配置时找不到选项。


解决方案

我使用流利的nhibernate,所以我会改变他们,像这样:

  var fluentConfiguration = Fluently.Configure(NHibernate.Cfg.Configuration()。Configure())
.Mappings(m =>
m.FluentMappings
.AddFromAssemblyOf< OrderMap>()
.Conventions.AddFromAssemblyOf< PascalCaseColumnNameConvention>())
.ProxyFactoryFactory(NHibernate.Bytecode.DefaultProxyFactoryFactory,NHibernate);

var config = fluentConfiguration.BuildConfiguration();

foreach(Config.ClassMappings中的PersistentClass persistentClass)
{
persistentClass.DynamicUpdate = true;
}

var sessionFactory = config.BuildSessionFactory();


How can I set DynamicUpdate and DynamicInsert on all my entities?

It works perfectly when I put it together with my mapping code, but I would like to specify it only once for my entire project.

I could not find an option when creating the Session or in the Configuration.

Any ideas?

解决方案

I use fluent nhibernate so I would change them like this:

var fluentConfiguration = Fluently.Configure(NHibernate.Cfg.Configuration().Configure())
      .Mappings(m =>
          m.FluentMappings
          .AddFromAssemblyOf<OrderMap>()
          .Conventions.AddFromAssemblyOf<PascalCaseColumnNameConvention>())
          .ProxyFactoryFactory("NHibernate.Bytecode.DefaultProxyFactoryFactory, NHibernate");

var config = fluentConfiguration.BuildConfiguration();

foreach(PersistentClass persistentClass in config.ClassMappings)
{
    persistentClass.DynamicUpdate = true;
}

var sessionFactory = config.BuildSessionFactory();

这篇关于NHibernate:如何在所有实体上设置DynamicUpdate?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆