예제 #1
0
        public static String MySqlTypeToCShpaeType(FieldProperty types)
        {
            string result = "";

            if (types.TypeName.ToLower().Contains("bit"))
            {
                if (types.TypeName.ToLower().Contains("no"))
                {
                    result = "bool";
                }
                else
                {
                    result = "bool?";
                }
                return(result);
            }
            if (types.TypeName.ToLower().Contains("bigint"))
            {
                if (types.TypeName.ToLower().Contains("no"))
                {
                    result = "long";
                }
                else
                {
                    result = "long?";
                }
                return(result);
            }
            if (types.TypeName.ToLower().Contains("int"))
            {
                if (types.TypeName.ToLower().Contains("no"))
                {
                    result = "int";
                }
                else
                {
                    result = "int?";
                }
                return(result);
            }
            if (types.TypeName.ToLower().Contains("double"))
            {
                if (types.TypeName.ToLower().Contains("no"))
                {
                    result = "double";
                }
                else
                {
                    result = "double?";
                }
                return(result);
            }

            if (types.TypeName.ToLower().Contains("float"))
            {
                if (types.TypeName.ToLower().Contains("no"))
                {
                    result = "float";
                }
                else
                {
                    result = "float?";
                }
                return(result);
            }

            if (types.TypeName.ToLower().Contains("decimal"))
            {
                if (types.TypeName.ToLower().Contains("no"))
                {
                    result = "decimal";
                }
                else
                {
                    result = "decimal?";
                }
                return(result);
            }
            if (types.TypeName.ToLower().Contains("varchar") || types.TypeName.ToLower().Contains("text"))
            {
                result = "string";
                return(result);
            }
            if (types.TypeName.ToLower().Contains("char"))
            {
                if (types.TypeName.ToLower().Contains("no"))
                {
                    result = "char";
                }
                else
                {
                    result = "char?";
                }
                return(result);
            }
            if (types.TypeName.ToLower().Contains("datetime"))
            {
                if (types.TypeName.ToLower().Contains("no"))
                {
                    result = "DateTime";
                }
                else
                {
                    result = "DateTime?";
                }
                return(result);
            }
            if (types.TypeName.ToLower().Contains("timestamp"))
            {
                if (types.TypeName.ToLower().Contains("no"))
                {
                    result = "long";
                }
                else
                {
                    result = "long?";
                }
                return(result);
            }

            return(result);
        }
예제 #2
0
        public static String SqlServiceTypeToCShpaeType(FieldProperty types)
        {
            string result = "";

            if (types.TypeName.ToLower().Contains("bigint"))
            {
                if (types.TypeName.ToLower().Contains("no"))
                {
                    result = "long";
                }
                else
                {
                    result = "long?";
                }
                return(result);
            }
            if (types.TypeName.ToLower().Contains("binary") || types.TypeName.ToLower().Contains("sql_variant"))
            {
                result = "object";
                return(result);
            }
            if (types.TypeName.ToLower().Contains("bit"))
            {
                if (types.TypeName.ToLower().Contains("no"))
                {
                    result = "bool";
                }
                else
                {
                    result = "bool?";
                }
                return(result);
            }
            if (types.TypeName.ToLower().Contains("datetime"))
            {
                if (types.TypeName.ToLower().Contains("no"))
                {
                    result = "DateTime";
                }
                else
                {
                    result = "DateTime?";
                }
                return(result);
            }
            if (types.TypeName.ToLower().Contains("decimal") ||
                types.TypeName.ToLower().Contains("money") ||
                types.TypeName.ToLower().Contains("smallmoney") ||
                types.TypeName.ToLower().Contains("numeric"))
            {
                if (types.TypeName.ToLower().Contains("no"))
                {
                    result = "decimal";
                }
                else
                {
                    result = "decimal?";
                }
                return(result);
            }

            if (types.TypeName.ToLower().Contains("float"))
            {
                if (types.TypeName.ToLower().Contains("no"))
                {
                    result = "double";
                }
                else
                {
                    result = "double?";
                }
                return(result);
            }
            if (types.TypeName.ToLower().Contains("real"))
            {
                if (types.TypeName.ToLower().Contains("no"))
                {
                    result = "float";
                }
                else
                {
                    result = "float?";
                }
                return(result);
            }
            if (types.TypeName.ToLower().Contains("image"))
            {
                result = "byte[]";
                return(result);
            }
            if (types.TypeName.ToLower().Contains("int"))
            {
                if (types.TypeName.ToLower().Contains("no"))
                {
                    result = "int";
                }
                else
                {
                    result = "int?";
                }
                return(result);
            }
            if (types.TypeName.ToLower().Contains("uniqueidentifier"))
            {
                if (types.TypeName.ToLower().Contains("no"))
                {
                    result = "Guid";
                }
                else
                {
                    result = "Guid?";
                }
                return(result);
            }

            if (types.TypeName.ToLower().Contains("char") ||
                types.TypeName.ToLower().Contains("nchar") ||
                types.TypeName.ToLower().Contains("ntext") ||
                types.TypeName.ToLower().Contains("text") ||
                types.TypeName.ToLower().Contains("varchar") ||
                types.TypeName.ToLower().Contains("nvarchar") ||
                types.TypeName.ToLower().Contains("xml"))
            {
                result = "string";
                return(result);
            }

            return(result);
        }