简体   繁体   中英

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:

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. 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.

您将必须动态地执行此操作,并且查看特定于提供程序的翻译可能很有意义(以便提供程序可以提供自己的映射)。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM