DapperLib / DapperLib/Dapper.Contrib
Dapper.Contrib Update ignores mapping
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 293
- Forks
- 109
- PR merge metrics
- No merged PRs in 30d
Description
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
public class SmUser{
public int Id { get; set; }
public string Name { get; set; }
public string FullName { get; set; }
public string Email { get; set; }
}
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
user.Email = user.Email + "z";
cn.Update(user);
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
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue through the Get and Update entry points using the shown SmUser model and underscore-named database field. Compare the mapping used for retrieval with the SQL generated by Update, then verify that updating the entity targets the existing full_name column instead of FullName.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, sql
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100