0

I am building my application using s#arp lite framework. One of my tables is called User. But User is a SQL Server 2008 keyword, so it gives me problems.

I tried to modify the code to support tables using SQL Server keywords, butcouldn't get it to work.

Here's the code.

https://github.com/codai/Sharp-Lite/blob/master/Example/MyStore/app/MyStore.NHibernateProvider/Conventions.cs

Line 32: I changed it to following code

classCustomizer.Table("[" + Inflector.Net.Inflector.Singularize(type.Name.ToString()) + "]");
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
qinking126
  • 11,385
  • 25
  • 74
  • 124

3 Answers3

3

I have already answered this on the mailing list, posting answer here for others to find easily (and the points :)

https://github.com/codai/Sharp-Lite/blob/master/Example/MyStore/app/MyStore.NHibernateProvider/NHibernateInitializer.cs#L19

add: db.KeywordsAutoImport = Hbm2DDLKeyWords.AutoQuote;

Should do the trick

Seif Attar
  • 632
  • 3
  • 9
0

This seems vaguely familiar to me. No promises but you can try to use quotes around User, like select * from "User" or supply the schema owner ase well, like select * from Mydb.User.

Hope this helps. Good luck!

Todd Murray
  • 423
  • 2
  • 7
0

You can also do this manually by utilizing NHibernate's non-DB specific escape character: the backtick `

In SQL Server you may do "[User]" but in Oracle it will be different. If you use "`User`" NHibernate will adapt this to the database you are currently working with.

This can be seen on this question: Fluent NHibernate Column Mapping with Reserved Word

Community
  • 1
  • 1
Origin
  • 1,943
  • 13
  • 33