sql到C#的数据类型转换

/// <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";
           }
 
       }

 

posted @ 2013-02-18 15:48  一抹、思乡泪  Views(473)  Comments(0Edit  收藏  举报