ruder

  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 :: 管理 ::
        protected static string GetSqlType(PropertyInfo info)
        {            
            string type = String.Empty;
            switch (info.PropertyType.Name.ToLower())
            {
                case "int":
                case "int16":                
                case "int32": type = "int"; break;
                case "int64": type = "bigint"; break;
                case "single":
                case "double": type = "money"; break;
                case "datetime": type = "datetime"; break;
                case "bool":
                case "boolean": type = "bit"; break;
                default: type = "[nvarchar] (100)"; break;
            }
            return type;
        }

        protected static DbType GetDbType(PropertyInfo info)
        {
            DbType type = DbType.String;
            switch (info.PropertyType.Name.ToLower())
            {
                case "int":
                case "int16":
                case "int32": type = DbType.Int32; break;
                case "int64": type = DbType.Int64; break;
                case "single":
                case "double": type =DbType.Double; break;
                case "datetime": type = DbType.DateTime2; break;
                case "bool":
                case "boolean": type = DbType.Binary; break;
                default: type = DbType.String; break;
            }
            return type;
        }
posted on 2009-04-29 17:36  徐境  阅读(173)  评论(0)    收藏  举报