I’m trying to store the “DataType” field value (type System.Type) of a DbDataReader.GetSchemaTable.DataRow to a class field of type System.Type.
i.e.:
Class MyClass
Private _ColumnName As String
Private _DataType As Type
Sub New(row As DataRow)
_ColumnName = Convert.ToString(row("ColumnName"))
_DataType = row("DataType")
End Sub
End Class
I can resolve the late binding problem with ColumnName by casting to string but I am at a loss as how to deal with the DataType.
If I use _DataType = row("DataType").GetType then System.RuntimeType is stored instead of the actual type.
If you know it’s an instance of Type, then use
DirectCast(row("DataType"), Type)