开发者

Castle ActiveRecord Table name conflict

开发者 https://www.devze.com 2022-12-28 16:30 出处:网络
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 brac开发者_开发问答kets for q

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 brac开发者_开发问答kets 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 {}

From the NHibernate Column class:

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.


Ok figured it out:

[ActiveRecord("[User]")]
    public class User : ActiveRecordBase
0

精彩评论

暂无评论...
验证码 换一张
取 消