Quoting column names with NHibernate and PostgreSQL

安稳与你 提交于 2019-12-03 06:31:55

Since hbm2ddl.keywords is supposed to do this for you and it not working, I would suggest you to grab nhibernate source, and debug it with your project.

Problably you can start with a breakpoint on SessionFactoryImpl.cs line 171

if (settings.IsAutoQuoteEnabled)

Take a look at method public static void QuoteTableAndColumns(Configuration configuration) on SchemaMetadataUpdater.cs

Hope that helps.

I realize this is a rather old question but for others that may end up here you could also implement a custom naming strategy, when setting up your session factory you would add:

Fluently.Configure(new Configuration()
    .SetNamingStrategy(new CustomNamingStrategy()))...

In CustomNamingStrategy, implement the interface NHibernate.Cfg.INamingStrategy and for all the methods basically just return the parameters with quotes around them.

Don't use uppercase characters in table/column names. That will solve this problem and make ad-hoc querying less painful as you won't have to keep quoting them.

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