NHibernate config properties in Fluent NHibernate

北城以北 提交于 2019-12-06 14:07:39

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";
}

Some of the settings are exposed through the fluent API.

See here for examples: Database Configuration

Anything that isn't supported through specific fluent calls can be set by manipulating the native NHibernate.Cfg.Configuration object. Either way you can do everything in code that you can with the configuration file.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!