MySql数据类型(MySqlDbType)名称对应.NET类型(Type)


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

扫一扫加微信


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