Shane
Shane

Reputation: 1191

Castle ActiveRecord Table name conflict

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?

Upvotes: 3

Views: 258

Answers (2)

Mauricio Scheffer
Mauricio Scheffer

Reputation: 99730

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.

Upvotes: 3

Shane
Shane

Reputation: 1191

Ok figured it out:

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

Upvotes: 1

Related Questions