在NHibernate中的列名中转义问号字符 [英] Escaping a question mark character in a column name in NHibernate

查看:122
本文介绍了在NHibernate中的列名中转义问号字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个实体,该实体的列名称包含问号.如何映射列名,以便HQL查询将正确生成带有适当包装的列名(即[SQL Server]为[])的SQL,而不是用参数代替问号?我曾尝试将列名称包装在反引号或方括号中,但这不起作用.

I have an entity with a property whose column name contains a question mark. How do I map the column name so that an HQL query will correctly generate SQL with the column name wrapped appropriately (i.e. [] for SQL Server) instead of substituting a parameter for the question mark? I have tried wrapping the column name in backticks or square brackets but this doesn't work.

推荐答案

反引号对我来说很好.请记住,仅在映射文件中使用它们,而不在HQL中使用它们:

Backticks work fine for me. Remember to use them only in the mapping file, not in the HQL:

<property name="Data1" column="`Data1?`" />

此查询:

session.CreateQuery("select Data1 from Foo").List();

此SQL的结果:

select foo0_.[Data1?] as col_0_0_
from Foo foo0_


更新:这是NHibernate 3.1中的错误. 吉拉问题已创建

这篇关于在NHibernate中的列名中转义问号字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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