Ability to handle nulls in a custom type handler
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 18.4k
- Forks
- 3.7k
- Avg merge
- 5h 8m
- Merged PRs (30d)
- 1
Description
In https://sodocumentation.net/dapper/topic/13/handling-nulls it states that nulls are handled as follows:
"values read that are null are presented as null, or (in the case of mapping to a known type) simply ignored (leaving their type-based default)"
Propose using the same pattern as ITypeHandlerParse to implement a INullTypeHandler to allow us to handle a null rather than being ignored. If not implemented this will then have no effect and therefore be safe / backwards compatible / no risk and have no runtime performance overhead.
The scenario this is useful for is if a user wants to differentiate between:
- A column being present in the result set but null
- A column not being present in a result set
An example of this would be implementing an Optional pattern
Below is a .net fiddle to demonstrate.
DotNetFiddle example
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 by reading the existing ITypeHandlerParse pattern and reviewing the linked DotNetFiddle example. Define what the proposed INullTypeHandler should do for a present null versus an absent column, then verify that existing behavior remains unchanged when no null handler is implemented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend, database
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 32/100