示例#1
0
        public override ISpecificType GenericTypeToSpecific(DbTypeBase type, IMigrationProfile profile, IProgressInfo progress)
        {
            switch (type.Code)
            {
            case DbTypeCode.Int:
                return(GetEfzTypeInt((DbTypeInt)type));

            case DbTypeCode.String:
                return(GetEfzTypeString((DbTypeString)type));

            case DbTypeCode.Logical:
                return(new EfzTypeBoolean());

            case DbTypeCode.Datetime:
            {
                string attr  = type.GetSpecificAttribute("effiproz", "subtype");
                var    dtype = type as DbTypeDatetime;
                if (attr == "timestamp")
                {
                    var res = new EfzTypeTimestamp();
                    res.Precision = Int32.Parse(type.GetSpecificAttribute("effiproz", "precision"));
                    return(res);
                }
                if (attr == "yeartomonth")
                {
                    var res = new EfzTypeIntervalYearToMonth();
                    //res.Precision = Int32.Parse(type.GetSpecificAttribute("effiproz", "precision"));
                    return(res);
                }
                if (attr == "daytosecond")
                {
                    var res = new EfzTypeIntervalDayToSecond();
                    //res.Precision = Int32.Parse(type.GetSpecificAttribute("effiproz", "precision"));
                    return(res);
                }
                if (attr == "date")
                {
                    var res = new EfzTypeDate();
                    return(res);
                }

                switch (dtype.SubType)
                {
                case DbDatetimeSubType.Date:
                    return(new EfzTypeDate());

                case DbDatetimeSubType.Datetime:
                    if (dtype.HasTimeZone)
                    {
                        return(new EfzTypeTimestampTz());
                    }
                    else
                    {
                        return(new EfzTypeTimestamp());
                    }

                case DbDatetimeSubType.Interval:
                    return(new EfzTypeIntervalDayToSecond());

                case DbDatetimeSubType.Time:
                    return(new EfzTypeTimestamp());

                case DbDatetimeSubType.Year:
                    return(new EfzTypeDate());
                }
                return(new EfzTypeTimestamp());
            }

            case DbTypeCode.Numeric:
            {
                var res = new EfzTypeNumber();
                res.Precision  = ((DbTypeNumeric)type).Precision;
                res.Scale      = ((DbTypeNumeric)type).Scale;
                res.IsIdentity = ((DbTypeNumeric)type).Autoincrement;

                int increment;
                if (Int32.TryParse(type.GetSpecificAttribute("effiproz", "identity_increment"), out increment))
                {
                    res.IdentityIncrement = increment;
                    res.IdentitySeed      = Int32.Parse(type.GetSpecificAttribute("effiproz", "identity_seed"));
                }
                return(res);
            }

            case DbTypeCode.Blob:
            {
                var    res  = new EfzTypeBlob();
                string size = type.GetSpecificAttribute("effiproz", "maxbytes");
                if (size != null)
                {
                    res.MaxBytes = Int32.Parse(size);
                }
                return(res);
            }

            case DbTypeCode.Text:
            {
                var    res  = new EfzTypeClob();
                string size = type.GetSpecificAttribute("effiproz", "maxbytes");
                if (size != null)
                {
                    res.MaxBytes = Int32.Parse(size);
                }
                return(res);
            }

            case DbTypeCode.Array:
                return(new EfzTypeClob());

            case DbTypeCode.Float:
                return(new EfzTypeDouble());

            case DbTypeCode.Xml:
                return(new EfzTypeClob());

            case DbTypeCode.Generic:
                return(new EfzTypeGeneric {
                    Sql = ((DbTypeGeneric)type).Sql
                });
            }
            throw new Exception("DAE-00323 unknown type");
        }
示例#2
0
        private EfzTypeBase MakeSpecificEfzType(string dt, int size, int digits)
        {
            switch (dt)
            {
            case "BOOLEAN":
            case "BIT":
                return(new EfzTypeBoolean());

            case "TINYINT":
                return(new EfzTypeTinyInt());

            case "SMALLINT":
                return(new EfzTypeSmallInt());

            case "INT":
            case "INTEGER":
                return(new EfzTypeInt());

            case "BIGINT":
                return(new EfzTypeBigInt());

            case "CHAR":
            case "NCHAR":
            case "CHARACTER":
            case "VARCHAR_IGNORECASE":
            {
                var res = new EfzTypeChar();
                res.Length = size;
                return(res);
            }

            case "VARCHAR":
            case "NVARCHAR":
            case "CHARACTER VARYING":
            {
                var res = new EfzTypeVarChar();
                res.Length = size;
                return(res);
            }

            case "NVARCHAR2":
            case "VARCHAR2":
            {
                var res = new EfzTypeVarChar2();
                res.Length = size;
                return(res);
            }

            case "BINARY":
            {
                var res = new EfzTypeBinary();
                res.Length = size;
                return(res);
            }

            case "VARBINARY":
            {
                var res = new EfzTypeVarBinary();
                res.Length = size;
                return(res);
            }

            case "DECIMAL":
            case "NUMERIC":
            case "NUMBER":
            {
                var res = new EfzTypeNumber();
                res.Precision = size;
                res.Scale     = digits;
                return(res);
            }

            case "TIMESTAMP":
            case "TIME":
            {
                var res = new EfzTypeTimestamp();
                return(res);
            }

            case "DATETIME":
            case "DATE":
            {
                var res = new EfzTypeDate();
                return(res);
            }

            case "TIMESTAMP WITH TIMEZONE":
            {
                var res = new EfzTypeTimestampTz();
                return(res);
            }

            case "UNIQUEIDENTIFIER":
            {
                var res = new EfzTypeUniqueIdentifier();
                return(res);
            }

            case "DOUBLE":
            {
                var res = new EfzTypeDouble();
                return(res);
            }

            case "CLOB":
            {
                var res = new EfzTypeClob();
                res.MaxBytes = size;
                return(res);
            }

            case "BLOB":
            {
                var res = new EfzTypeBlob();
                res.MaxBytes = size;
                return(res);
            }
            }
            ReportUnknownType(dt);
            return(new EfzTypeGeneric {
                Sql = dt
            });
        }