Exemplo n.º 1
0
        private ISpecificType GetPostgreSqlTypeInt(DbTypeInt type)
        {
            string subtype = type.GetSpecificAttribute("pgsql", "subtype");

            switch (subtype)
            {
            case "oid": return(new PostgreSqlTypeOid());
            }

            if (type.Autoincrement)
            {
                if (type.Bytes == 8)
                {
                    return(new PostgreSqlTypeBigSerial());
                }
                return(new PostgreSqlTypeSerial());
            }
            if (type.Bytes == 8)
            {
                return(new PostgreSqlTypeBigInt());
            }
            if (type.Bytes == 2)
            {
                return(new PostgreSqlTypeSmallInt());
            }
            return(new PostgreSqlTypeInteger());
        }
Exemplo n.º 2
0
        private ISpecificType GetAccessTypeInt(DbTypeInt type)
        {
            AccessTypeIntBase res;

            switch (type.Bytes)
            {
            case 1:
                res = new AccessTypeTinyInt();
                break;

            case 2:
                res = new AccessTypeSmallInt();
                break;

            case 4:
                res = new AccessTypeInteger();
                break;

            default:
                res = new AccessTypeTinyInt();
                break;
            }
            res.IsAutoIncrement = type.Autoincrement;
            return(res);
        }
Exemplo n.º 3
0
        public override DbTypeBase ToGenericType()
        {
            DbTypeInt res = new DbTypeInt();

            res.Autoincrement = IsAutoIncrement;
            return(res);
        }
Exemplo n.º 4
0
        protected override DbTypeBase ToGenericTypeNoArray()
        {
            DbTypeInt res = new DbTypeInt();

            res.Bytes = 8;
            return(res);
        }
Exemplo n.º 5
0
        public override DbTypeBase ToGenericType()
        {
            DbTypeInt res = new DbTypeInt();

            res.Bytes    = 4;
            res.Unsigned = false;
            return(res);
        }
Exemplo n.º 6
0
        protected override DbTypeBase ToGenericTypeNoArray()
        {
            DbTypeInt res = new DbTypeInt();

            res.Bytes = 4;
            res.SetSpecificAttribute("pgsql", "subtype", "oid");
            return(res);
        }
Exemplo n.º 7
0
        protected override DbTypeBase ToGenericTypeNoArray()
        {
            DbTypeInt res = new DbTypeInt();

            res.Bytes         = 4;
            res.Autoincrement = true;
            return(res);
        }
Exemplo n.º 8
0
        ITableStructure GetStructure(DbfFile dbf)
        {
            var res = new TableStructure();

            //output column names
            for (int i = 0; i < dbf.Header.ColumnCount; i++)
            {
                DbTypeBase type;
                // convert DBF type to DA type
                switch (dbf.Header[i].ColumnType)
                {
                case DbfColumn.DbfColumnType.Binary:
                    type = new DbTypeBlob();
                    break;

                case DbfColumn.DbfColumnType.Boolean:
                    type = new DbTypeLogical();
                    break;

                case DbfColumn.DbfColumnType.Date:
                    type = new DbTypeDatetime {
                        SubType = DbDatetimeSubType.Date
                    };
                    break;

                case DbfColumn.DbfColumnType.Character:
                    type = new DbTypeString {
                        Length = dbf.Header[i].Length
                    };
                    break;

                case DbfColumn.DbfColumnType.Integer:
                    type = new DbTypeInt();
                    break;

                case DbfColumn.DbfColumnType.Memo:
                    type = new DbTypeText();
                    break;

                case DbfColumn.DbfColumnType.Number:
                    type = new DbTypeNumeric {
                        Precision = dbf.Header[i].DecimalCount
                    };
                    break;

                default:
                    type = new DbTypeString();
                    break;
                }
                res.AddColumn(dbf.Header[i].Name, type);
            }
            return(res);
        }
Exemplo n.º 9
0
        public override DbTypeBase ToGenericType()
        {
            DbTypeInt res = new DbTypeInt();

            res.Bytes    = Bytes;
            res.Unsigned = false;
            if (IsIdentity)
            {
                res.Autoincrement = true;
                res.SetSpecificAttribute("effiproz", "identity_increment", IdentityIncrement.ToString());
                res.SetSpecificAttribute("effiproz", "identity_seed", IdentitySeed.ToString());
            }
            return(res);
        }
Exemplo n.º 10
0
        private MySqlTypeBase GetMySqlTypeInt(DbTypeInt type)
        {
            if (type.GetSpecificAttribute("mysql", "subtype") == "bit")
            {
                MySqlTypeBit bit = new MySqlTypeBit();
                bit.Length = Int32.Parse(type.GetSpecificAttribute("mysql", "bitlength"));
                return(bit);
            }

            MySqlTypeInteger res;

            switch (type.Bytes)
            {
            case 1:
                res = new MySqlTypeTinyInt();
                break;

            case 2:
                res = new MySqlTypeSmallInt();
                break;

            case 3:
                res = new MySqlTypeMediumInt();
                break;

            case 4:
                res = new MySqlTypeInt();
                break;

            case 8:
                res = new MySqlTypeBigInt();
                break;

            default:
                res = new MySqlTypeInt();
                break;
            }
            res.IsAutoIncrement = type.Autoincrement;
            res.Unsigned        = type.Unsigned;
            res.Zerofill        = type.GetSpecificAttribute("mysql", "zerofill") == "1";
            string len = type.GetSpecificAttribute("mysql", "length");

            if (len != null)
            {
                res.Length = Int32.Parse(len);
            }
            return(res);
        }
Exemplo n.º 11
0
        public static string GetSqlType(Type type)
        {
            DbTypeBase res;

            if (type == typeof(SqlString))
            {
                res = new DbTypeString();
            }
            else if (type == typeof(SqlInt32))
            {
                res = new DbTypeInt {
                    Bytes = 4
                }
            }
            ;
            else if (type == typeof(SqlInt16))
            {
                res = new DbTypeInt {
                    Bytes = 2
                }
            }
            ;
            else if (type == typeof(SqlInt64))
            {
                res = new DbTypeInt {
                    Bytes = 8
                }
            }
            ;
            else if (type == typeof(SqlDecimal))
            {
                res = new DbTypeNumeric();
            }
            else
            {
                res = TypeTool.GetDatAdminType(type);
            }

            if (res is DbTypeString)
            {
                var stype = (DbTypeString)res;
                stype.Length    = 4000;
                stype.IsUnicode = true;
            }
            return(MsSqlDialect.Instance.GenericTypeToSpecific(res).ToString());
        }
Exemplo n.º 12
0
        private SqlTypeBase GetSqlTypeInt(DbTypeInt type)
        {
            SqlTypeInteger res;

            switch (type.Bytes)
            {
            case 1:
                // tinyint is unsigned, when type is signed,
                // we must use 2-byte signed int
                if (type.Unsigned)
                {
                    res = new SqlTypeTinyInt();
                }
                else
                {
                    res = new SqlTypeSmallInt();
                }
                break;

            case 2:
                res = new SqlTypeSmallInt();
                break;

            case 4:
                res = new SqlTypeInt();
                break;

            case 8:
                res = new SqlTypeBigInt();
                break;

            default:
                res = new SqlTypeInt();
                break;
            }
            res.IsIdentity = type.Autoincrement;
            int increment;

            if (Int32.TryParse(type.GetSpecificAttribute("mssql", "identity_increment"), out increment))
            {
                res.IdentityIncrement = increment;
                res.IdentitySeed      = Int32.Parse(type.GetSpecificAttribute("mssql", "identity_seed"));
            }
            return(res);
        }
Exemplo n.º 13
0
 public override DbTypeBase ToGenericType()
 {
     if (m_length == 1)
     {
         var res = new DbTypeLogical();
         res.SetSpecificAttribute("mysql", "subtype", "bit");
         return(res);
     }
     else
     {
         var res = new DbTypeInt {
             Bytes = 8, Unsigned = true
         };
         res.SetSpecificAttribute("mysql", "subtype", "bit");
         res.SetSpecificAttribute("mysql", "bitlength", Length.ToString());
         return(res);
     }
 }
Exemplo n.º 14
0
 public override DbTypeBase ToGenericType()
 {
     if (Precision == null && Scale == null)
     {
         var fres = new DbTypeFloat {
             Bytes = 8
         };
         fres.SetSpecificAttribute("oracle", "subtype", "number");
         return(fres);
     }
     if (Precision != null && Scale != null)
     {
         var nres = new DbTypeNumeric();
         nres.Precision = Precision.Value;
         nres.Scale     = Scale.Value;
         return(nres);
     }
     if ((Scale ?? 0) == 0)
     {
         var ires = new DbTypeInt {
             Bytes = 4
         };
         if (Precision != null)
         {
             ires.SetSpecificAttribute("oracle", "length", Precision.ToString());
         }
         return(ires);
     }
     if (Precision == null)
     {
         var nres = new DbTypeNumeric();
         nres.Scale = Scale.Value;
         nres.SetSpecificAttribute("oracle", "noprec", "1");
         return(nres);
     }
     // this should never happen
     return(new DbTypeNumeric());
 }
Exemplo n.º 15
0
        private EfzTypeBase GetEfzTypeInt(DbTypeInt type)
        {
            EfzTypeInteger res;

            switch (type.Bytes)
            {
            case 1:
                res = new EfzTypeTinyInt();
                break;

            case 2:
                res = new EfzTypeSmallInt();
                break;

            case 4:
                res = new EfzTypeInt();
                break;

            case 8:
                res = new EfzTypeBigInt();
                break;

            default:
                res = new EfzTypeInt();
                break;
            }
            res.IsIdentity = 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);
        }