Conversation
| // Example using a module-level attribute | ||
| using Dapper; | ||
|
|
||
| [module: TypeHandler<YourDotNetType, YourCustomTypeHandler>] |
There was a problem hiding this comment.
If I have a query that required certain set of typeHandlers,
And other do not,
Then how to restore them, and then add if and when needed ?
There was a problem hiding this comment.
Hello, this PR does not currently allow for switching or disabling type handlers on the fly.
This is definitely a feature that could be added, though.
|
Any update on this PR or #117? I am debugging custom Dapper.AOT I have registered them via and they are not used in source generation and I just get runtime cast errors when loading data from DB "Invalid cast from 'System.Int64' to 'MyCustomType'." What is the purpose of |
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
TypeHandlerobject 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
TypeHandlerInstanceRegistryand modifies the code generation to ensure that:__Handler1,__Handler2).