-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dapper.Contrib character case bug #12
Comments
I found a way around this field name problem for the time being. in my Repository Constructor i used: DapperExtensions.DapperExtensions.SqlDialect = new DapperExtensions.Sql.PostgreSqlDialect(); and in the Insert Method: db.Insert(item); i did not use the SqlMapper approach, nor did I use the SqlMapperExtensions.Insert() Ive tried on .Net Core 2.1 Lambda, and AWS Aurora 10.7. Dapper v2.0.30 I hope this helps others for now....in the interim. |
Hi @rclarke2050 Does it mean that we have to include DapperExtenssions library to achieve this? DapperExtenssions and DapperContrib seem to be doing same thing but different way. I was thinking to choose between both of them. |
try either, and you'll know which one works for your scenarios. In terms of how i managed it, setting the SQLDialect did the trick. |
Hi @rclarke2050 Actually, both didn't work for me really. Each had its own limitations. I had to write my own solution to generate Insert and Update queries using Reflection and Humanizer with some if/else. It seems to work just fine and really isn't too much. It is very compact than I thought it could possibly be. Here is the gist. You could customize it to suit your own specific needs but it works for me throughout my project. |
I'm a little confused. Why would Dapper.Contrib have anything to do with Dapper-Extensions? Dapper.Contrib doesn't use the "dialect" approach to determine platform. Rather it tries to check the IDbConnection and then formats some of the strings accordingly.
|
Adding ExplicitKey attribute on my Id worked for me. But important point is you have to set "Id" key yourself. Edit: Adding Computed attribute with changing it from Id to something like ItemId or ProductId solves the problem for sequential primary keys. |
@dogac00, are you going to re-submit you PR (this one) in the new Dapper.Contrib repo for traying to solve this issue ? |
Just to follow up. For instance in Here |
Hi!
I have table in postgres created with field names in quotes (i.e. case sensitive):
and c# class also with case sensitive properties:
When I try to insert record with InsertAsync, it throws an error
as you can see, column "id" is written here in lower case, because the function InsertAsync skips id-column during query creation.
UpdateAsync works perfectly because it uses "Id" in where clause.
But when I change the name of column in database to "id" - InsertAsync works good, but UpdateAsync fails by the same reason.
Please help.
The text was updated successfully, but these errors were encountered: