现在的位置: 首页 > 综合 > 正文

sql到C#的数据类型转换

2012年06月08日 ⁄ 综合 ⁄ 共 709字 ⁄ 字号 评论关闭
/// <summary>
       /// sql到C#的数据类型转换
       /// </summary>
       /// <param name="typename">sql数据类型名称</param>
       /// <returns>C#名称</returns>
       public static string SqlToCsharp(string typename)
       {
 
           switch (typename)
           {
               case "bit": return "Boolean";
               case "bigint": return "Int64";
               case "int": return "Int32";
               case "smallint": return "Int16";
               case "tinyint": return "Byte";
               case "numeric":
               case "money":
               case"smallmoney":
               case "decimal": return "Decimal";
               case "float": return "Double";
               case "real": return "Single";
               case "smalldatetime":
               case"timestamp":
               case "datetime": return "DateTime";
               case "char":
               case"varchar":
               case "text":
               case "Unicode":
               case"nvarchar":
               case "ntext": return "string";
               case"binary":
               case"varbinary":
               case "image": return "Byte[]";
               case "uniqueidentifier": return "Guid";
               default: return "Object";
           }
 
       }

 

抱歉!评论已关闭.