I am using Dapper.Rainbow and have come across an issue when inserting into a table named 'User'.
I can get other tables to work perfectly, but when try to insert to the Users
table it will fail.
I have used the Sql Query inspector to determine that the generated query does not have any [ ]
around the table name. Once I recraft the query with square brackets, it works fine.
When I use Table<User>(this, "[Users]");
it will set the private property likelyTableName
to the correct value ([User]
).
However as soon as database.Init(dbconn,3);
it will change the likelyTableName
string back to User
.
I have been checking out the Dapper-dot-net Github project and looked through the database.cs source for dapper.rainbow, but am at a loss as parts of it are in IL.
Is there a way to get dapper.rainbow to work with a table named User
??
It is really a bad idea to use reserved words for table (or field, view etc) names. I think that is likely causing you problems. Better to bite the bullet once and change the name, than fight with it forever.
For reference, here are a list of reserved words (to avoid):
http://msdn.microsoft.com/en-us/library/ms189822.aspx