NHibernate的配置属性在流利NHibernate的 [英] NHibernate config properties in Fluent NHibernate

查看:126
本文介绍了NHibernate的配置属性在流利NHibernate的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑对我的项目使用Fluent NHibernate,并且我还没有找到任何关于FH是否支持NHibernate设置(如show_sql和prepare_sql)的文档。我可以在没有show_sql的情况下生活,但是prepare_sql对于在运行时确保良好的性能非常重要。



任何人都可以告诉我是否可以在Fluent NHibernate中配置这些设置?

解决方案

是的,您可以。

  b .Exfiguration()
.Database(ConfigureDatabase())
.Mappings(ConfigureMapping)
.ExposeConfiguration(ModifyConfiguration)
.BuildConfiguration();

现在在 ModifyConfiguration NHibernate 配置要修改的对象

  private void ModifyConfiguration(Configuration configuration)
{
//设置参数如下:
configuration.Properties [show_sql] =true;
}


I am considering using Fluent NHibernate for my project and I haven't found any documentation on whether FH supports NHibernate settings such as show_sql and prepare_sql. I could live without show_sql in a pinch, but prepare_sql is important for ensuring good performance at run time.

Can anyone tell me if it's possible to configure these settings in Fluent NHibernate?

解决方案

Yes, you can.

Fluently.Configure()
    .Database(ConfigureDatabase())
    .Mappings(ConfigureMapping)
    .ExposeConfiguration(ModifyConfiguration)
    .BuildConfiguration();

And now in ModifyConfiguration method you have plain NHibernate's Configuration object to modify

private void ModifyConfiguration(Configuration configuration)
{
    // set parameters here like this:
    configuration.Properties["show_sql"] = "true";
}

这篇关于NHibernate的配置属性在流利NHibernate的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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