How do I best convert a System.Data.DbType enumeration value to the corresponding (or at least one of the possible corresponding) System.Type values?
For example:
DbType.StringFixedLength -> System.String DbType.String -> System.String DbType.Int32 -> System.Int32
I’ve only seen very ‘dirty’ solutions but nothing really clean.
(yes, it’s a follow up to a different question of mine, but it made more sense as two seperate questions)
AFAIK there is no built-in converter in .NET for converting a SqlDbType to a System.Type. But knowing the mapping you can easily roll your own converter ranging from a simple dictionary to more advanced (XML based for extensability) solutions.
The mapping can be found here: http://www.carlprothman.net/Default.aspx?tabid=97