CSharp examples for System.Reflection:Type
Sql Type To Csharp Type String
using System.Text; using System.Linq; using System.Data; using System.Collections.Generic; using System;// w w w .j a v a2 s. co m public class Main{ public static string SqlTypeToCsharpTypeString(string sqlType) { switch (sqlType.ToLower()) { case "bit": return "DbType.Boolean"; case "nchar": case "ntext": case "nvarchar": case "nvarchar2": case "char": case "text": case "varchar": case "varchar2": case "nclob": case "clob": case "long": case "rowid": return "DbType.String"; case "datetime": case "datetime2": case "date": case "datetimeoffset": case "smalldatetime": case "time": case "timestamp": case "interval day to second": return "DbType.DateTime"; case "money": case "decimal": case "smallmoney": case "number": case "integer": return "DbType.Decimal"; case "float": return "DbType.Double"; case "smallint": return "DbType.Int16"; case "int": case "interval year to month": return "DbType.Int32"; case "bigint": return "DbType.Int64"; case "real": case "binary_float": return "DbType.Single"; case "tinyint": return "DbType.Byte"; case "uniqueidentifier": return "DbType.Guid"; case "binary": case "image": case "udt"://?????????? case "varbinary": case "variant": case "xml": case "bfile": case "blob": case "long raw": case "raw": default: return "DbType.Object"; } } }