SetValue is not invoked in a Dapper custom TypeHandler
Open
Nobody has claimed this yet.
breaking-change
v3.0
- Dominant language
- C#
- Stars
- 18.4k
- Forks
- 3.7k
- Avg merge
- 5h 8m
- Merged PRs (30d)
- 1
Description
As per THIS question:
Given:
public class GuidHandler : SqlMapper.TypeHandler<Guid>
{
public override void SetValue(IDbDataParameter parameter, Guid value)
{
// My Custom logic
}
public override Guid Parse(object value)
{
return Guid.Parse(value.ToString());
}
}
...
SqlMapper.AddTypeHandler(new GuidHandler());
Even though the Parse is correctly invoked when reading from the DB, the SetValue however never gets called when writing the data.
Any idea of what is going on?
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
Start with the GuidHandler and SqlMapper.AddTypeHandler registration shown in the issue, then trace how Dapper handles the type when writing parameters versus reading values. Confirm the expected behavior for a Guid write and identify whether SetValue is reached; done means the custom SetValue logic is invoked during writes without breaking Parse on reads.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100