DapperAOT icon indicating copy to clipboard operation
DapperAOT copied to clipboard

feat: TypeHandler support

Open 7amou3 opened this issue 5 months ago • 1 comments

This PR represents an attempt to resolve issue #159.

The prior approach of the source generator (#117) inadvertently led to the generation of code that instantiated a new TypeHandler object for each parameter or column read operation (new global::CustomClassTypeHandler().Read(...)). This could lead to unnecessary object allocations and a minor performance overhead, especially in high-volume scenarios.

This PR introduces a TypeHandlerInstanceRegistry and modifies the code generation to ensure that:

  • A single, static instance of each registered TypeHandler is created within the generated interceptor file (e.g., __Handler1, __Handler2).
  • All subsequent operations (setting parameters, parsing output parameters, reading result set columns) for a given type handler utilize this pre-allocated, static instance.

7amou3 avatar Jul 20 '25 16:07 7amou3