Anybody got a C# function that maps the SQL datatype of a column to its CLR equivalent?

后端 未结 12 1716
逝去的感伤
逝去的感伤 2020-12-12 16:18

I\'m sitting down to write a massive switch() statement to turn SQL datatypes into CLR datatypes in order to generate classes from MSSQL stored procedures. I\'m using this c

12条回答
  •  难免孤独
    2020-12-12 17:08

    Normally I just use the Value property to convert a SqlType to a native .NET type. This does the job most of the time. If I have a corner case, I'll just write a quick helper function.

    int i = dataReader.GetSqlInt32(0).Value;
    

提交回复
热议问题