TypeHandler Override -> SetValue not being called.
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 18.4k
- Forks
- 3.7k
- Avg merge
- 5h 8m
- Merged PRs (30d)
- 1
Description
I have posted this on StackOverflow but I think it might be a bug, unless I'm missing something super simple.
Am trying to add a custom type handler for an F# Union Type. ParseValue works fine but SetValue does not seem to get called at all.
type PrimaryKey<'x> =
| Id of int
| EmptyPrimaryKey
..
type PrimaryKeyHandler<'X>() =
inherit SqlMapper.TypeHandler<PrimaryKey<'X>>()
override _.SetValue(param, value) =
let valueOrNull =
match value with
| Id x -> box x
| EmptyPrimaryKey -> null
param.DbType <- DbType.Int32 (* Put in as a test , doesn't seem to do anything*)
param.Value <- valueOrNull
override _.Parse value =
if isNull value || value = box DBNull.Value
then EmptyPrimaryKey
else Id (value :?> int)
Anything obvious jump out here?
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 Dapper's SqlMapper.TypeHandler implementation and the registration and parameter-binding path used by the PrimaryKeyHandler example. Reproduce the reported case and trace whether SetValue is reached; done means the handler is invoked and assigns the expected DbType and Value for both union cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, fsharp
- Domain
- database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100