Search code examples
sql-servercastle-activerecord

Castle Active Record can not execute query because table name is equal to a keyword


I am trying to do the "getting started" from Castle Active record, now I got into this problem could not execute query exception

select count(*) as col_0_0_ from User user0_ where 1=1 //it's SQL Server 2008

question: Can I somehow make castle put the table name into [] like [User]?


Solution

  • In the [ActiveRecord] attribute, you can define the name of the table. Example:

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