0

i have class named Group

i tried to test configuration:

var cfg = new Configuration();
cfg.Configure();

cfg.AddAssembly(typeof (Group).Assembly);

new SchemaExport(cfg).Execute(true, true, false);

when i debug this, im getting following sql:

 create table Group (
        ID INT IDENTITY NOT NULL,
       Name NVARCHAR(255) null,
       CreatedDate DATETIME null,
       primary key (ID)
    )

so like i remember, Group key reserved for Group By

so why NHibernate does not uses quotes like Group for table names?

BTW, I'm using Sql Server 2005 and NHibernate 2.1

1 Answer 1

1

If you are using a reserved keyword as your object name you should mark it with a DBMS specific sign. For example if you are using SQL Server you should put it in [] and use ` for MySql. In this example you should write (assuming that you are using SQL server) :

<class name="Group" table="[Group]"> 
Sign up to request clarification or add additional context in comments.

1 Comment

In NHibernate, you can use ` and it will be translated to the appropriate database quoting mechanism.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.