c# - How do you get the Type of any basic system object or primitive -
i'm trying intelligently populate object results of sql query. i'm looping through results of sqldatareader , using getdatatypename() string representation of data type held in particular field.
how can automatically type of each field without manually mapping string names types. i've tried using:
type.gettype(reader.getdatatypename(), true, true) (note, case-sensitivity ignored)
but getdatatypename() returns strings of primitives such "int" , these throw typeloadexceptions example given.
i've read gettype() requires assembly qualified type name non-primitive system types datetime need qualified "system.datetime", prefixing "system" namespace "int" doesn't primitive type such this.
there no need parse here; use:
type type = reader.getfieldtype(columnindex);
Comments
Post a Comment