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.

有帮助吗?

解决方案

You're going to have to do this dynamically, and it may make sense to look at a provider-specific translation (so providers can supply their own mappings).

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top