views:

118

answers:

1

I'm using NHibernate with SQL Server 2005.

SQL rejects my Schema because I have an unquoted column name "User" which was auto generate from the property of my domain object.

  <class name="Entity" table="Entities" lazy="false">
    <id name="Id" />
    <property name="User"/>
    <property name="Domain"/>
    <property name="Password"/>
  </class>

I've tried the following config fragment:

configuration.Properties["keywords"] = "auto-quote";

But I still get the same error.

I've written a INamingStrategy to quote all table and column names, but this seems slightly over kill but I don't what to have to manually set the column names for my mapping.

See http://nhforge.org/blogs/nhibernate/archive/2009/06/24/auto-quote-table-column-names.aspx for more detail on how it should work

A: 

Looks like the fail safe way is to create an INamingStrategy implementation that wraps the default naming strategy but adds "`" (backticks) around all table and column names to escape any keywords.

The documentation says that the configuration in the question should work, but it doesn't seem to this case.

DLKJ