Beispiel #1
0
        private SqlTypeBase GetSqlTypeString(DbTypeString type)
        {
            SqlTypeCharacter res;

            if (type.GetSpecificAttribute("mssql", "subtype") == "uniqueidentifier")
            {
                return(new SqlTypeUniqueIdentifier());
            }
            if (type.IsVarLength)
            {
                if (type.IsUnicode)
                {
                    res = new SqlTypeNVarChar();
                }
                else if (type.IsBinary)
                {
                    res = new SqlTypeVarBinary();
                }
                else
                {
                    res = new SqlTypeVarChar();
                }
            }
            else
            {
                if (type.IsUnicode)
                {
                    res = new SqlTypeNChar();
                }
                else if (type.IsBinary)
                {
                    res = new SqlTypeBinary();
                }
                else
                {
                    res = new SqlTypeChar();
                }
            }
            res.Length = type.Length;
            return(res);
        }
Beispiel #2
0
        private SqlTypeBase MakeSpecificSqlType(string dt, int len, int prec, int scale)
        {
            switch (dt)
            {
            case "binary":
            {
                SqlTypeBinary res = new SqlTypeBinary();
                res.Length = len;
                return(res);
            }

            case "image":
                return(new SqlTypeImage());

            case "timestamp":
                return(new SqlTypeTimestamp());

            case "varbinary":
            {
                SqlTypeVarBinary res = new SqlTypeVarBinary();
                res.Length = len;
                return(res);
            }

            case "bit":
                return(new SqlTypeBit());

            case "tinyint":
                return(new SqlTypeTinyInt());

            case "datetime":
                return(new SqlTypeDatetime());

            case "datetime2":
                return(new SqlTypeDatetime2());

            case "datetimeoffset":
                return(new SqlTypeDatetimeOffset());

            case "date":
                return(new SqlTypeDate());

            case "time":
                return(new SqlTypeTime());

            case "smalldatetime":
                return(new SqlTypeSmallDatetime());

            case "decimal":
            {
                SqlTypeDecimal res = new SqlTypeDecimal();
                res.Precision = prec;
                res.Scale     = scale;
                return(res);
            }

            case "numeric":
            {
                SqlTypeNumeric res = new SqlTypeNumeric();
                res.Precision = prec;
                res.Scale     = scale;
                return(res);
            }

            case "float":
                return(new SqlTypeFloat());

            case "uniqueidentifier":
                return(new SqlTypeUniqueIdentifier());

            case "smallint":
                return(new SqlTypeSmallInt());

            case "int":
                return(new SqlTypeInt());

            case "bigint":
                return(new SqlTypeBigInt());

            case "real":
                return(new SqlTypeReal());

            case "char":
            {
                SqlTypeChar res = new SqlTypeChar();
                res.Length = len;
                return(res);
            }

            case "nchar":
            {
                SqlTypeNChar res = new SqlTypeNChar();
                res.Length = len;
                return(res);
            }

            case "varchar":
            {
                SqlTypeVarChar res = new SqlTypeVarChar();
                res.Length = len;
                return(res);
            }

            case "nvarchar":
            {
                SqlTypeNVarChar res = new SqlTypeNVarChar();
                res.Length = len;
                return(res);
            }

            case "text":
                return(new SqlTypeText());

            case "ntext":
                return(new SqlTypeNText());

            case "xml":
                return(new SqlTypeXml());

            case "money":
                return(new SqlTypeMoney());

            case "smallmoney":
                return(new SqlTypeSmallMoney());

            case "sql_variant":
                return(new SqlTypeVariant());
            }
            ReportUnknownType(dt);
            return(new SqlTypeGeneric {
                Sql = dt
            });
        }