-
Notifications
You must be signed in to change notification settings - Fork 100
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 Update ignores mapping #2
Comments
This feature is not supported . In Dapper.Contrib.SqlMapperExtensions.cs are fetched only the properties from the entity type and constructs directly the update statement. DefaultTypeMap.MatchNamesWithUnderscores or any implementation of SqlMapper.ITypeMap is not taken in account. I ll give it a try myself |
Same for Dapper: 1.50.0-rc2 and Dapper.Contrib: 1.50.0-beta8 |
I've created a pull request that implements the mapping for Insert and Update the last week, but I don't know if the maintainer have seen it yet. |
Nice work! I'm happy to test it as soon as gets integrated. |
Wow, I was really counting on this working. The db schema I'm using still has some old tables in it with underscored columns and the classes all utilize CamelCase property names. I went to test some updates and that didn't go so well. |
Is this really not addressed 4 years later? |
|
+1 |
1 similar comment
+1 |
My take on this to update a Class with lots of properties:
This logic can be made into a reusable function with parameters as necessary. Example: To snake_case from PascalCase converter as:
|
|
Is this repo still maintained? |
Is this really not addressed 6 years later? |
+1 |
This is almost obligatory to have underscores in Postgres - given the way it handles case and quotes. Hence I don't quite understand how anyone using Postgres can use Dapper.Contrib... I can't |
Is this really not addressed 7 years later? |
For anyone looking for an alternative, I went with FastCrud after years of using Dapper.Contrib. Luckily it was a "drop in" replacement that didn't require any code changes (for me at least) and supported the |
this problem not fixed until today :( |
do someone have alternative? |
Hi,
some fields in my table have underscores like full_name so i did
DefaultTypeMap.MatchNamesWithUnderscores = true;
which works just fine when i retrieve entity with Get<> but throws "Invalid column name 'FullName'."
when i update
my model
Whet i run Get it works just fine, the property FullName is populated with data
var user = cn.Get<SmUser>(id);
but when i update the entity
i get
An exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll but was not handled in user code
"Invalid column name 'FullName'."
and the sql query
update smuser set [Name] = @Name, [FullName] = @FullName, [Email] = @Email where [Id] = @Id
"FullName" is the entity property, "full_name" is the db field
using dapper 1.42
The text was updated successfully, but these errors were encountered: