How to convert strings such as "uniqueidentifier"
, "timestamp"
, "image"
, "money"
, "sql_variant"
etc. into respective .net data-types?
I need to query a table to find out its contained fields and then accumulate those into a list List<Column>
. Column
is a class written by me. So I need this mechanism.
Simply work out what you want the types to be (which may vary by your database) and use a dictionary:
Note that this is assuming you're using C# 3, as it uses a collection initializer. Let me know if you're not using C# 3.
EDIT: Here's the C# 2 code: