将SQLServer数据类型转换为C#.Net类型
将SQLServer数据类型转换为C#.Net类型
/// <summary>
/// 将SQLServer数据类型(如:varchar)转换为.Net类型(如:String)
/// </summary>
/// <param name="sqlTypeString">SQLServer数据类型</param>
/// <returns></returns>
public static string SqlTypeName2DotNetType(string sqlTypeString)
{
string[] SqlTypeNames = new string[] { "int", "varchar","bit" ,"datetime","decimal","float","image","money",
"ntext","nvarchar","smalldatetime","smallint","text","bigint","binary","char","nchar","numeric",
"real","smallmoney", "sql_variant","timestamp","tinyint","uniqueidentifier","varbinary"};
string[] DotNetTypes = new string[] {"int", "string","bool" ,"DateTime","Decimal","Double","Byte[]","Single",
"string","string","DateTime","Int16","string","Int64","Byte[]","string","string","Decimal",
"Single","Single", "Object","Byte[]","Byte","Guid","Byte[]"};
int i = Array.IndexOf(SqlTypeNames, sqlTypeString.ToLower());
return DotNetTypes[i];
}
// 来源:www.CSFramework.com, C/S结构框架学习网
/// 将SQLServer数据类型(如:varchar)转换为.Net类型(如:String)
/// </summary>
/// <param name="sqlTypeString">SQLServer数据类型</param>
/// <returns></returns>
public static string SqlTypeName2DotNetType(string sqlTypeString)
{
string[] SqlTypeNames = new string[] { "int", "varchar","bit" ,"datetime","decimal","float","image","money",
"ntext","nvarchar","smalldatetime","smallint","text","bigint","binary","char","nchar","numeric",
"real","smallmoney", "sql_variant","timestamp","tinyint","uniqueidentifier","varbinary"};
string[] DotNetTypes = new string[] {"int", "string","bool" ,"DateTime","Decimal","Double","Byte[]","Single",
"string","string","DateTime","Int16","string","Int64","Byte[]","string","string","Decimal",
"Single","Single", "Object","Byte[]","Byte","Guid","Byte[]"};
int i = Array.IndexOf(SqlTypeNames, sqlTypeString.ToLower());
return DotNetTypes[i];
}
// 来源:www.CSFramework.com, C/S结构框架学习网
扫一扫加作者微信
版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
NewDoc C/S框架网