Exemplo n.º 1
0
        public override ISpecificType GenericTypeToSpecific(DbTypeBase type, IMigrationProfile profile, IProgressInfo progress)
        {
            switch (type.Code)
            {
            case DbTypeCode.Int:
                return(GetAccessTypeInt((DbTypeInt)type));

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

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

            case DbTypeCode.Datetime:
                return(new AccessTypeDatetime());

            case DbTypeCode.Numeric:
            {
                AccessTypeDecimal res = new AccessTypeDecimal();
                res.Precision       = ((DbTypeNumeric)type).Precision;
                res.Scale           = ((DbTypeNumeric)type).Scale;
                res.IsAutoIncrement = ((DbTypeNumeric)type).Autoincrement;
                return(res);
            }

            case DbTypeCode.Blob:
                return(new AccessTypeImage());

            case DbTypeCode.Text:
            case DbTypeCode.Array:
                return(new AccessTypeText());

            case DbTypeCode.Float:
            {
                DbTypeFloat tp = (DbTypeFloat)type;
                if (tp.IsMoney)
                {
                    return(new AccessTypeMoney());
                }
                if (tp.Bytes == 4)
                {
                    return(new AccessTypeReal());
                }
                else
                {
                    return(new AccessTypeFloat());
                }
            }

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

            case DbTypeCode.Generic:
                return(new AccessTypeGeneric {
                    Sql = ((DbTypeGeneric)type).Sql
                });
            }
            throw new InternalError("DAE-00058 unknown type");
        }
Exemplo n.º 2
0
        private AccessTypeBase MakeSpecificAccessType(string dt, int len, int prec, int scale)
        {
            switch (dt.ToLower())
            {
            case "short":
                return(new AccessTypeSmallInt());

            case "long":
                return(new AccessTypeInteger());

            case "single":
                return(new AccessTypeReal());

            case "double":
                return(new AccessTypeFloat());

            case "currency":
                return(new AccessTypeMoney());

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

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

            case "byte":
                return(new AccessTypeTinyInt());

            case "guid":
                return(new AccessTypeUniqueIdentifier());

            case "longbinary":
            case "bigbinary":
                return(new AccessTypeImage());

            case "varbinary":
                return(new AccessTypeBinary());

            case "longtext":
                return(new AccessTypeText());

            case "varchar":
            {
                if (len == 0)
                {
                    return(new AccessTypeText());
                }
                AccessTypeCharacter res = new AccessTypeCharacter();
                res.Length = len;
                return(res);
            }

            case "decimal":
            {
                AccessTypeDecimal res = new AccessTypeDecimal();
                res.Precision = prec;
                res.Scale     = scale;
                return(res);
            }
            }
            ReportUnknownType(dt);
            return(new AccessTypeGeneric {
                Sql = dt
            });
            //throw new DbAnalyseError(String.Format("Unknown MS Access type:{0}", dt));
        }