public string DataType2CSharpType(System.Data.DbType dbType)
{
switch (dbType)
{
case DbType.AnsiString:
return "string";
case DbType.AnsiStringFixedLength:
return "string";
case DbType.Binary:
return "byte[]";
case DbType.Boolean:
return "bool";
case DbType.Byte:
return "byte";
case DbType.Currency:
return "decimal";
case DbType.Date:
return "DateTime";
case DbType.DateTime:
return "DateTime";
case DbType.DateTime2:
return "DateTime";
case DbType.DateTimeOffset:
return "DateTime";
case DbType.Decimal:
return "decimal";
case DbType.Double:
return "double";
case DbType.Guid:
return "Guid";
case DbType.Int16:
return "short";
case DbType.Int32:
return "int";
case DbType.Int64:
return "long";
case DbType.Object:
return "object";
case DbType.SByte:
return "sbyte";
case DbType.Single:
return "float";
case DbType.String:
return "string";
case DbType.StringFixedLength:
return "string";
case DbType.Time:
return "DateTime";
case DbType.UInt16:
return "ushort";
case DbType.UInt32:
return "uint";
case DbType.UInt64:
return "ulong";
case DbType.VarNumeric:
return "decimal";
case DbType.Xml:
return "string";
default:
return "object";
}
}
转载于:https://www.cnblogs.com/T_max_Csharp/archive/2011/03/18/1987606.html