-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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.
- TypeHandler<> can't override default typeMap for base types #206 TypeHandler<> can't override default typeMap for base types
- TypeHandler not working correctly with DynamicParameters #275 TypeHandler not working correctly with DynamicParameters
- Custom type handlers for enums are ignored #259 Custom type handlers for enums are ignored
- Non-nullable TypeHandler passed DBNull when selecting scalar results #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.