c# - casting a string to OdbcType enum -


I need to make examples of Odibiseepametr at run time by using the values ​​returned as the database characteristics I my problem It is given that the data type is given as a string in uppercase, which is why Enum.Parse or Enum.TryParse fails to cast its string to it is the correspondable value of enum: < / P> Datatype = (ODBC Type) on Enum.Parse (tie) F (OdbcType), "NVARCHAR");

To solve this issue I have created a dictionary:

  public stable dictionary & lt; String, odbt type & gt; OdbcDataTypeDictionary = new dictionary & lt; String, odbctype & gt; () {{ "BIGINT", OdbcType.BigInt}, { "Binary", OdbcType.Binary}, { "bit", OdbcType.Bit}, { "four", OdbcType.Char}, { "date", OdbcType. Date}, { "DATETIME", OdbcType.DateTime}, { "decimal", OdbcType.Decimal}, { "double", OdbcType.Double}, { "image", OdbcType.Image}, { "INT", OdbcType. Int}, { "NCHAR", OdbcType.NChar}, { "ntext", OdbcType.NText}, { "NUMERIC", OdbcType.Numeric}, { "NVARCHAR", OdbcType.NVarChar}, { "real", OdbcType. Real}, { "SMALLDATETIME", OdbcType.SmallDateTime}, { "SMALLINT", OdbcType.SmallInt}, { "text", OdbcType.Text}, { "time", OdbcType.Time}, { "TIMESTAMP", OdbcType. Timestamp}, { "TINYINT", OdbcType.TinyInt}, { "uniqueidentifier", OdbcType.UniqueIdentifier}, { "VARBINARY", ODBC Taipkwarbri}}, { "VARCHAR", ODBC type. Worker}};  

It's working, but I'm not sure whether this is the best solution.

Do anyone have a better idea to solve this?

There is another boolean parameter to ignore the case of Enum.TryParse, which


Comments