DapperLib / DapperLib/Dapper

Use TypeHandler for all types

Open
#433 6 comments 8 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

v3.0
Dominant language
C#
Stars
18.4k
Forks
3.7k
Avg merge
5h 8m
Merged PRs (30d)
1

Description

Currently there is a separation between built-in types and custom types that use ITypeHandler.
There seems to be a common theme of bugs/enhancements that all revolve around this separation.

  • #206 TypeHandler<> can't override default typeMap for base types
  • #275 TypeHandler not working correctly with DynamicParameters
  • #259 Custom type handlers for enums are ignored
  • #224 Non-nullable TypeHandler passed DBNull when selecting scalar results

I was thinking its worth investigating if the type handling could be unified, so that both the in-built types and custom type handlers use the same mechanism so that the code handling types can be simplified in to, look up type handler, check for an optimizer, otherwise just use the type handler.

This would need to introduce a new enhanced type handler that can optionally generate IL to convert the to/from the database value. This would then allow custom type handlers to also generate optimized IL to convert the value.

This shouldn't have any significant impact on query times as type handlers are only looked up once when generating the IL for the query.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing ITypeHandler and the separate built-in type-handling paths, then review linked issues #206, #275, #259, and #224. Done means built-in and custom types use a unified handler lookup, with optional optimized IL conversion available to custom handlers without regressing the reported cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
database
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.