示例#1
0
        // ---------- Static convenience methods ----------

        /// <summary>
        /// Creates a table with a single column with the given name and type.
        /// </summary>
        /// <param name="database"></param>
        /// <param name="columnName"></param>
        /// <param name="c"></param>
        /// <returns></returns>
        internal static TemporaryTable SingleColumnTable(IDatabase database, String columnName, Type c)
        {
            DataType       ttype   = PrimitiveTypes.FromType(c);
            DataColumnInfo colInfo = new DataColumnInfo(null, columnName, ttype);
            TemporaryTable table   = new TemporaryTable(database, "single", new DataColumnInfo[] { colInfo });

            //      int type = TypeUtil.ToDbType(c);
            //      TableField[] fields =
            //                 { new TableField(columnName, type, Integer.MAX_VALUE, false) };
            //      TemporaryTable table = new TemporaryTable(database, "single", fields);
            return(table);
        }
示例#2
0
        public Database(IDatabaseContext context)
        {
            DatabaseContext = context;

            DiscoverDataVersion();

            TableComposite = new TableSourceComposite(this);

            // Create the single row table
            var t = new TemporaryTable(context, "SINGLE_ROW_TABLE", new ColumnInfo[0]);
            t.NewRow();
            SingleRowTable = t;

            TransactionFactory = new DatabaseTransactionFactory(this);
        }
示例#3
0
        // ---------- Static convenience methods ----------
        /// <summary>
        /// Creates a table with a single column with the given name and type.
        /// </summary>
        /// <param name="database"></param>
        /// <param name="columnName"></param>
        /// <param name="c"></param>
        /// <returns></returns>
        internal static TemporaryTable SingleColumnTable(IDatabase database, String columnName, Type c)
        {
            DataType ttype = PrimitiveTypes.FromType(c);
            DataColumnInfo colInfo = new DataColumnInfo(null, columnName, ttype);
            TemporaryTable table = new TemporaryTable(database, "single", new DataColumnInfo[] { colInfo });

            //      int type = TypeUtil.ToDbType(c);
            //      TableField[] fields =
            //                 { new TableField(columnName, type, Integer.MAX_VALUE, false) };
            //      TemporaryTable table = new TemporaryTable(database, "single", fields);
            return table;
        }
示例#4
0
        public void TestSetUp()
        {
            var tableName = ObjectName.Parse("APP.test_table");
            var tableInfo = new TableInfo(tableName);
            tableInfo.AddColumn("id", PrimitiveTypes.Numeric(), true);
            tableInfo.AddColumn("name", PrimitiveTypes.String(SqlTypeCode.VarChar));
            tableInfo.AddColumn("date", PrimitiveTypes.DateTime());

            cornerTime = DateTimeOffset.UtcNow;

            var tmpTable = new TemporaryTable(tableInfo);

            AddRow(tmpTable, 1, "test1", cornerTime);
            AddRow(tmpTable, 2, "test2", cornerTime.AddSeconds(2));
            AddRow(tmpTable, 3, "test3", cornerTime.AddSeconds(5));

            tmpTable.BuildIndexes(DefaultIndexTypes.BlindSearch);

            table = tmpTable;
        }
示例#5
0
 private void AddRow(TemporaryTable tmpTable, long id, string name, DateTimeOffset date)
 {
     var row = new DataObject[3];
     row[0] = DataObject.BigInt(id);
     row[1] = DataObject.String(name);
     row[2] = DataObject.Date(date);
     tmpTable.NewRow(row);
 }