MySQL数据类型(MySqlDbType)数据类型名称对应DbType类型


C# Code:
/// <summary>
/// MySql数据类型(如:varchar)对应DbType类型
/// MySQL数据类型(MySqlDbType)数据类型名称对应DbType类型
/// </summary>
public static IDictionary<string, DbType> MySqlDbTypeName2DbTypeMapping
{
get
{
IDictionary<string, DbType> map = new Dictionary<string, DbType>();
map.Add("BigInt", DbType.Int64);
map.Add("Binary", DbType.Binary);
map.Add("Bit", DbType.Boolean);
map.Add("Blob", DbType.Binary);
map.Add("Char", DbType.AnsiStringFixedLength);
map.Add("Byte", DbType.Byte);
map.Add("Date", DbType.Date);
map.Add("DateTime", DbType.DateTime);
map.Add("Decimal", DbType.Decimal);
map.Add("Double", DbType.Double);
map.Add("Enum", DbType.String);//enum可以自定义类型,常用的是0,1,也可以定义为boy,girl,secret
map.Add("Float", DbType.Double);
map.Add("Geometry", DbType.Object);
map.Add("Guid", DbType.Guid);
map.Add("Int", DbType.Int32);
map.Add("Integer", DbType.Int32);
map.Add("Int16", DbType.Int16);
map.Add("Int24", DbType.Int32);
map.Add("Int32", DbType.Int32);
map.Add("Int64", DbType.Int64);
map.Add("JSON", DbType.String);
map.Add("LongBlob", DbType.Binary);
map.Add("LongText", DbType.String);
map.Add("MediumBlob", DbType.Binary);
map.Add("MediumText", DbType.String);
map.Add("Newdate", DbType.DateTime);
map.Add("NewDecimal", DbType.Decimal);
map.Add("Numeric", DbType.Decimal);
map.Add("Real", DbType.Double);
map.Add("Set", DbType.String);
map.Add("String", DbType.String);
map.Add("SmallInt", DbType.Int16);
map.Add("Text", DbType.String);
map.Add("Time", DbType.Time);
map.Add("Timestamp", DbType.DateTime);
map.Add("TinyBlob", DbType.Binary);
map.Add("TinyInt", DbType.Int16);
map.Add("TinyText", DbType.String);
map.Add("UByte", DbType.Byte);
map.Add("UInt16", DbType.UInt16);
map.Add("UInt24", DbType.UInt32);
map.Add("UInt32", DbType.UInt32);
map.Add("UInt64", DbType.UInt64);
map.Add("VarBinary", DbType.Binary);
map.Add("VarChar", DbType.String);
map.Add("VarString", DbType.String);
map.Add("Year", DbType.Int32);
return map;
}
}
//来源:C/S框架网 | www.csframework.com | QQ:23404761
/// MySql数据类型(如:varchar)对应DbType类型
/// MySQL数据类型(MySqlDbType)数据类型名称对应DbType类型
/// </summary>
public static IDictionary<string, DbType> MySqlDbTypeName2DbTypeMapping
{
get
{
IDictionary<string, DbType> map = new Dictionary<string, DbType>();
map.Add("BigInt", DbType.Int64);
map.Add("Binary", DbType.Binary);
map.Add("Bit", DbType.Boolean);
map.Add("Blob", DbType.Binary);
map.Add("Char", DbType.AnsiStringFixedLength);
map.Add("Byte", DbType.Byte);
map.Add("Date", DbType.Date);
map.Add("DateTime", DbType.DateTime);
map.Add("Decimal", DbType.Decimal);
map.Add("Double", DbType.Double);
map.Add("Enum", DbType.String);//enum可以自定义类型,常用的是0,1,也可以定义为boy,girl,secret
map.Add("Float", DbType.Double);
map.Add("Geometry", DbType.Object);
map.Add("Guid", DbType.Guid);
map.Add("Int", DbType.Int32);
map.Add("Integer", DbType.Int32);
map.Add("Int16", DbType.Int16);
map.Add("Int24", DbType.Int32);
map.Add("Int32", DbType.Int32);
map.Add("Int64", DbType.Int64);
map.Add("JSON", DbType.String);
map.Add("LongBlob", DbType.Binary);
map.Add("LongText", DbType.String);
map.Add("MediumBlob", DbType.Binary);
map.Add("MediumText", DbType.String);
map.Add("Newdate", DbType.DateTime);
map.Add("NewDecimal", DbType.Decimal);
map.Add("Numeric", DbType.Decimal);
map.Add("Real", DbType.Double);
map.Add("Set", DbType.String);
map.Add("String", DbType.String);
map.Add("SmallInt", DbType.Int16);
map.Add("Text", DbType.String);
map.Add("Time", DbType.Time);
map.Add("Timestamp", DbType.DateTime);
map.Add("TinyBlob", DbType.Binary);
map.Add("TinyInt", DbType.Int16);
map.Add("TinyText", DbType.String);
map.Add("UByte", DbType.Byte);
map.Add("UInt16", DbType.UInt16);
map.Add("UInt24", DbType.UInt32);
map.Add("UInt32", DbType.UInt32);
map.Add("UInt64", DbType.UInt64);
map.Add("VarBinary", DbType.Binary);
map.Add("VarChar", DbType.String);
map.Add("VarString", DbType.String);
map.Add("Year", DbType.Int32);
return map;
}
}
//来源:C/S框架网 | www.csframework.com | QQ:23404761

扫一扫加微信


版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
NewDoc C/S框架网