[英]Is there a generic way of passing a DbType as a parameter
I need to execute this parameterized query, or an equivalent: 我需要执行此参数化查询或等效查询:
ALTER TABLE tableName ADD COLUMN ? ?
with the parameters as the name of the new column, and the data type. 使用参数作为新列的名称以及数据类型。 For example, if I pass in 'Name' DbType.Double, then it would resolve to:
例如,如果我传入“名称” DbType.Double,则它将解析为:
ALTER TABLE tablename ADD COLUMN Name FLOAT
I can't just create a mapping between DbType and the name of the field type, as the code's working on the IDbConnection
interface, not a specific implementation. 我不能仅仅在DbType和字段类型的名称之间创建映射,因为代码在
IDbConnection
接口上工作,而不是特定的实现。 Is there a generic way of doing this? 有通用的方法可以做到这一点吗? Right now I've got a separate mapping for each implementation, which is obviously far from ideal.
现在,我为每个实现都有一个单独的映射,这显然不理想。
您将必须动态地执行此操作,并且查看特定于提供程序的翻译可能很有意义(以便提供程序可以提供自己的映射)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.