internal SqlType GetSqlType()
        {
            switch (SqlType)
            {
            case SqlTypeCode.Boolean:
            case SqlTypeCode.Bit:
                return(PrimitiveTypes.Boolean(SqlType));

            case SqlTypeCode.TinyInt:
            case SqlTypeCode.SmallInt:
            case SqlTypeCode.Integer:
            case SqlTypeCode.BigInt:
                return(PrimitiveTypes.Numeric(SqlType));

            case SqlTypeCode.Real:
            case SqlTypeCode.Float:
            case SqlTypeCode.Decimal:
            case SqlTypeCode.Double:
            case SqlTypeCode.Numeric:
                return(PrimitiveTypes.Numeric(SqlType, Precision, Scale));

            case SqlTypeCode.String:
            case SqlTypeCode.Char:
            case SqlTypeCode.VarChar:
                return(PrimitiveTypes.String(SqlType, Size));

            case SqlTypeCode.Binary:
            case SqlTypeCode.VarBinary:
                return(PrimitiveTypes.Binary(SqlType, Size));

            case SqlTypeCode.Time:
            case SqlTypeCode.Date:
            case SqlTypeCode.DateTime:
            case SqlTypeCode.TimeStamp:
                return(PrimitiveTypes.DateTime(SqlType));

            case SqlTypeCode.DayToSecond:
            case SqlTypeCode.YearToMonth:
                return(PrimitiveTypes.Interval(SqlType));

            case SqlTypeCode.Clob:
            case SqlTypeCode.LongVarChar:
                return(PrimitiveTypes.Clob(Size));

            case SqlTypeCode.Blob:
            case SqlTypeCode.LongVarBinary:
                return(PrimitiveTypes.Blob(Size));

            default:
                throw new NotSupportedException();
            }
        }
Exemplo n.º 2
0
        private void InsertData(IQuery query)
        {
            var tableName = ObjectName.Parse("APP.test_table");
            var table     = query.Access().GetMutableTable(tableName);

            var data = CreateData(query, testData);

            var row = table.NewRow();

            row["id"]         = Field.Integer(1);
            row["first_name"] = Field.String("Antonello");
            row["last_name"]  = Field.String("Provenzano");
            row["birth_date"] = Field.Date(new SqlDateTime(1980, 06, 04));
            row["active"]     = Field.BooleanTrue;
            row["data"]       = new Field(PrimitiveTypes.Blob(2048), data);

            table.AddRow(row);
        }
Exemplo n.º 3
0
        private void CreateTable(IQuery query)
        {
            var tableName = ObjectName.Parse("APP.test_table");

            query.Access().CreateTable(table => table
                                       .Named(tableName)
                                       .WithColumn(column => column
                                                   .Named("id")
                                                   .HavingType(PrimitiveTypes.Integer())
                                                   .WithDefault(SqlExpression.FunctionCall("UNIQUEKEY",
                                                                                           new SqlExpression[] { SqlExpression.Constant(tableName.FullName) })))
                                       .WithColumn("first_name", PrimitiveTypes.String())
                                       .WithColumn("last_name", PrimitiveTypes.String())
                                       .WithColumn("birth_date", PrimitiveTypes.DateTime())
                                       .WithColumn("active", PrimitiveTypes.Boolean())
                                       .WithColumn("data", PrimitiveTypes.Blob(2048)));

            query.Session.Access().AddPrimaryKey(tableName, "id", "PK_TEST_TABLE");
        }