【问题标题】:Disable Table Name Double Quoting on FluentNhibernate在 FluentNhibernate 上禁用表名双引号
【发布时间】:2011-06-08 18:32:43
【问题描述】:

我正在将我的应用程序切换到 Postgresql,我的架构中的所有表都是小写的,当我使用 NHibernate 进行查询时,它会在映射上的表名中添加双引号在 PascalCase 中并导致查询失败,告诉我该表不存在。

我可以轻松转到所有映射类并将 Table 方法更改为小写, 就像从 'Table("UserAccount")' 更改为 'Table("useraccount")' 但我宁愿不必这样做..

我想知道是否有任何方法可以告诉 nhibernate 不要在查询中对表进行双引号,以便正确找到它。

我试过这个:

PostgreSQLConfiguration.Standard.Raw("hbm2ddl.keywords","none").ConnectionString(x => x.Is(_connectionString));

它没有工作。我几乎会告诉 nhibernate 不要担心大小写,但在使用 postgres 时会遇到麻烦。

【问题讨论】:

    标签: nhibernate postgresql case case-sensitive quote


    【解决方案1】:

    您可以使用 Fluent NHibernate 的 IClassConvention 更改此行为。我想根据this问题,这里没有其他方法可以做到

    【讨论】:

    • 哦,非常感谢...是的,有一个简单的方法可以做到这一点,nhibernate 已经为 table 预定义了约定,所以我只需要将这一行添加到会话配置中:m.FluentMappings.AddFromAssemblyOf<UserAccount>().Conventions.Add(Table.Is(x => x.TableName.ToLower()); 谢谢很多
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-11-26
    • 2013-05-10
    • 1970-01-01
    • 2013-06-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多