城堡ActiveRecord表名称冲突 [英] Castle ActiveRecord Table name conflict

查看:85
本文介绍了城堡ActiveRecord表名称冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当您在NHibernate中遇到诸如用户"之类的保留字时,您只需在有问题的文本周围加上单引号,然后nHibernate将在文本周围加上方括号以进行查询.我的问题是,您如何使用Castle.ActiveRecord做同样的事情?

When you run into a reserved word like "User" in NHibernate you would just put single quotes around the offending text and nHibernate will surround the text with square brackets for querying. My question is how do you do the same thing using Castle.ActiveRecord?

推荐答案

实际上,表达这一点的可移植方式是使用反引号,例如:

Actually, the portable way to express this is using backticks, e.g.:

[ActiveRecord("`User`")]
class User {}

来自 NHibernate列类:

如果传入一个值,则为 由`然后NHibernate包裹 将在SQL为时引用该列 为此产生的.列如何 引用取决于方言.

If a value is passed in that is wrapped by ` then NHibernate will Quote the column whenever SQL is generated for it. How the column is quoted depends on the Dialect.

这篇关于城堡ActiveRecord表名称冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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