문제

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