我最好如何转换的DbType到的System.Type? [英] How do I best convert a DbType to System.Type?

查看:395
本文介绍了我最好如何转换的DbType到的System.Type?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何最好的一个的System.Data.DbType枚举值转换为System.Type的价值?

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?

例如:

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没有内置的转换器在.NET中的转换的SqlDbType到一个System.Type的。但我们知道映射到更先进(基于XML的extensability)解决方案,您可以轻松地推出自己的转换,从一个简单的字典。

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.

的映射可以在这里找到: http://www.carlprothman.net/Default.aspx?tabid=97

The mapping can be found here: http://www.carlprothman.net/Default.aspx?tabid=97

这篇关于我最好如何转换的DbType到的System.Type?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆