Esempio n. 1
0
 public ReferenceTable(Table parent, ObjectName name)
     : base(parent)
 {
     tableInfo = new DataTableInfo(name);
     parent.TableInfo.CopyColumnsTo(tableInfo);
     tableInfo.IsReadOnly = true;
 }
Esempio n. 2
0
        internal ReferenceTable(Table table, DataTableInfo info)
            : base(table)
        {
            table_name = info.TableName;

            modifiedTableInfo = info;
        }
Esempio n. 3
0
        internal ReferenceTable(Table table, DataTableInfo info)
            : base(table)
        {
            table_name = info.TableName;

            modifiedTableInfo = info;
        }
Esempio n. 4
0
 public ReferenceTable(Table parent, ObjectName name)
     : base(parent)
 {
     tableInfo = new DataTableInfo(name);
     parent.TableInfo.CopyColumnsTo(tableInfo);
     tableInfo.IsReadOnly = true;
 }
Esempio n. 5
0
        public TestTable CreateTable(DataTableInfo tableInfo)
        {
            var table = new TestTable(tableInfo);

            tables[tableInfo.TableName] = table;
            return(table);
        }
Esempio n. 6
0
        /// <summary>
        /// Adds a column map into this table.
        /// </summary>
        /// <param name="mapping">The array containing a map to the column in
        /// the parent table that we want the column number to reference.</param>
        /// <param name="aliases"></param>
        public void SetColumnMap(int[] mapping, ObjectName[] aliases)
        {
            reverse_column_map = new int[Parent.ColumnCount];
            for (int i = 0; i < reverse_column_map.Length; ++i)
            {
                reverse_column_map[i] = -1;
            }
            column_map = mapping;

            this.aliases = aliases;

            DataTableInfo parentInfo = Parent.TableInfo;

            subsetTableInfo = new DataTableInfo(parentInfo.TableName);

            for (int i = 0; i < mapping.Length; ++i)
            {
                int            map_to  = mapping[i];
                DataColumnInfo colInfo = Parent.GetColumnInfo(map_to).Clone();
                colInfo.Name = aliases[i].Name;
                subsetTableInfo.AddColumn(colInfo);
                reverse_column_map[map_to] = i;
            }

            subsetTableInfo.IsReadOnly = true;
        }
Esempio n. 7
0
        public SubsetColumnTable(Table parent, int[] mapping, ObjectName[] aliases)
            : base(parent)
        {
            int[] reverseColumnMap = new int[Parent.TableInfo.ColumnCount];
            for (int i = 0; i < reverseColumnMap.Length; ++i)
            {
                reverseColumnMap[i] = -1;
            }

            DataTableInfo parentInfo = Parent.TableInfo;

            subsetTableInfo = new SubsetTableInfo(parentInfo.Name);

            for (int i = 0; i < mapping.Length; ++i)
            {
                int            mapTo     = mapping[i];
                DataColumnInfo colInfo   = Parent.TableInfo[mapTo];
                var            newColumn = subsetTableInfo.NewColumn(aliases[i].Name, colInfo.DataType);
                newColumn.DefaultExpression = colInfo.DefaultExpression;
                newColumn.IsNullable        = colInfo.IsNullable;

                subsetTableInfo.AddColumn(colInfo);
                reverseColumnMap[mapTo] = i;
            }

            subsetTableInfo.Setup(mapping, aliases);
            subsetTableInfo.IsReadOnly = true;
        }
Esempio n. 8
0
        /// <summary>
        /// Copies the object, excluding the columns and the constraints
        /// contained in it.
        /// </summary>
        /// <returns></returns>
        public DataTableInfo NoColumnClone()
        {
            DataTableInfo info = new DataTableInfo(tableName);

            info.tableTypeName = tableTypeName;
            return(info);
        }
Esempio n. 9
0
 public TableQueryInfo(IDatabaseConnection conn, DataTableInfo tableInfo, ObjectName tableName, ObjectName aliasedAs)
 {
     this.conn      = conn;
     this.tableInfo = tableInfo;
     this.aliasedAs = aliasedAs;
     this.tableName = tableName;
 }
Esempio n. 10
0
        internal DataColumnInfo(DataTableInfo tableInfo, string name, DataType dataType)
        {
            TableInfo = tableInfo;
            DataType  = dataType;
            Name      = name;

            IsNullable = true;
        }
Esempio n. 11
0
        internal DataColumnInfo(DataTableInfo tableInfo, string name, DataType dataType)
        {
            TableInfo = tableInfo;
            DataType = dataType;
            Name = name;

            IsNullable = true;
        }
Esempio n. 12
0
        internal ReferenceTable(Table table, ObjectName tname)
            : base(table)
        {
            table_name = tname;

            // Create a modified table info based on the parent info.
            modifiedTableInfo            = table.TableInfo.Clone(tname);
            modifiedTableInfo.IsReadOnly = true;
        }
Esempio n. 13
0
        internal ReferenceTable(Table table, ObjectName tname)
            : base(table)
        {
            table_name = tname;

            // Create a modified table info based on the parent info.
            modifiedTableInfo = table.TableInfo.Clone(tname);
            modifiedTableInfo.IsReadOnly = true;
        }
Esempio n. 14
0
        ///<summary>
        ///</summary>
        ///<param name="crossRefTable"></param>
        ///<param name="inExpList"></param>
        ///<param name="columnNames"></param>
        ///<param name="context"></param>
        public FunctionTable(Table crossRefTable, Expression[] inExpList, string[] columnNames, IQueryContext context)
            : base(context.Connection.Database)
        {
            // Make sure we are synchronized over the class.
            lock (typeof(FunctionTable)) {
                uniqueId = UniqueKeySeq;
                ++UniqueKeySeq;
            }
            uniqueId = (uniqueId & 0x0FFFFFFF) | 0x010000000;

            this.context = context;

            this.crossRefTable = crossRefTable;
            crResolver         = crossRefTable.GetVariableResolver();
            crResolver.SetId   = 0;

            // Create a DataTableInfo object for this function table.
            funTableInfo = new DataTableInfo(FunctionTableName);

            expList = new Expression[inExpList.Length];
            expInfo = new byte[inExpList.Length];

            // Create a new DataColumnInfo for each expression, and work out if the
            // expression is simple or not.
            for (int i = 0; i < inExpList.Length; ++i)
            {
                Expression expr = inExpList[i];
                // Examine the expression and determine if it is simple or not
                if (expr.IsConstant() && !expr.HasAggregateFunction(context))
                {
                    // If expression is a constant, solve it
                    DataObject result = expr.Evaluate(null, null, context);
                    expr       = Expression.Constant(result);
                    expList[i] = expr;
                    expInfo[i] = 1;
                }
                else
                {
                    // Otherwise must be dynamic
                    expList[i] = expr;
                    expInfo[i] = 0;
                }
                // Make the column info
                funTableInfo.AddColumn(columnNames[i], expr.ReturnType(crResolver, context));
            }

            // Make sure the table info isn't changed from this point on.
            funTableInfo.IsReadOnly = true;

            // Function tables are the size of the referring table.
            row_count = crossRefTable.RowCount;

            // Set schemes to 'blind search'.
            BlankSelectableSchemes(1);
        }
Esempio n. 15
0
        internal DataColumnInfo(DataTableInfo tableInfo, string name, DataType type)
        {
            if (name == null)
                throw new ArgumentNullException("name");
            if (type == null)
                throw new ArgumentNullException("type");

            this.tableInfo = tableInfo;
            this.name = name;
            this.type = type;
        }
Esempio n. 16
0
        ///<summary>
        ///</summary>
        ///<param name="database"></param>
        ///<param name="name"></param>
        ///<param name="fields"></param>
        public TemporaryTable(IDatabase database, String name, DataColumnInfo[] fields)
            : base(database)
        {
            tableStorage = new List<DataObject[]>();

            tableInfo = new DataTableInfo(new ObjectName(null, name));
            foreach (DataColumnInfo field in fields) {
                tableInfo.AddColumn(field.Clone());
            }
            tableInfo.IsReadOnly = true;
        }
Esempio n. 17
0
        private static int RequireColumnIndex(DataTableInfo tableInfo, string columnName)
        {
            var offset = tableInfo.FindColumnName(columnName);

            if (offset == -1)
            {
                throw new ArgumentException(String.Format("Table {0} has no column named {1}", tableInfo.Name, columnName));
            }

            return(offset);
        }
Esempio n. 18
0
        ///<summary>
        ///</summary>
        ///<param name="database"></param>
        ///<param name="name"></param>
        ///<param name="fields"></param>
        public TemporaryTable(IDatabase database, String name, DataColumnInfo[] fields)
            : base(database)
        {
            tableStorage = new List <DataObject[]>();

            tableInfo = new DataTableInfo(new ObjectName(null, name));
            foreach (DataColumnInfo field in fields)
            {
                tableInfo.AddColumn(field.Clone());
            }
            tableInfo.IsReadOnly = true;
        }
Esempio n. 19
0
        internal void CopyColumnsTo(DataTableInfo tableInfo)
        {
            foreach (var column in columns)
            {
                var newColumn = new DataColumnInfo(tableInfo, column.Name, column.DataType)
                {
                    DefaultExpression = column.DefaultExpression,
                    IsNullable        = column.IsNullable
                };

                tableInfo.AddColumn(newColumn);
            }
        }
Esempio n. 20
0
        public DataTableInfo Clone(ObjectName newTableName)
        {
            DataTableInfo clone = new DataTableInfo(newTableName);

            clone.tableTypeName = (string)tableTypeName.Clone();
            clone.columns       = new List <DataColumnInfo>();
            foreach (DataColumnInfo column in columns)
            {
                clone.columns.Add(column.Clone());
            }

            return(clone);
        }
Esempio n. 21
0
        /// <summary>
        /// This is called when an index to a row needs to be removed from the
        /// SelectableScheme objects.
        /// </summary>
        /// <param name="rowNumber"></param>
        /// <remarks>
        /// This occurs when we have a modification log of row removals that haven't
        /// actually happened to old backed up scheme.
        /// </remarks>
        internal void RemoveRowToColumnSchemes(int rowNumber)
        {
            int           col_count = ColumnCount;
            DataTableInfo tableInfo = TableInfo;

            for (int i = 0; i < col_count; ++i)
            {
                if (tableInfo[i].IsIndexableType)
                {
                    SelectableScheme ss = GetRootColumnScheme(i);
                    ss.Remove(rowNumber);
                }
            }
        }
Esempio n. 22
0
        /// <summary>
        /// This is called when a row is in the table, and the SelectableScheme
        /// objects for each column need to be notified of the rows existance,
        /// therefore build up the relational model for the columns.
        /// </summary>
        /// <param name="rowNumber"></param>
        internal void AddRowToColumnSchemes(int rowNumber)
        {
            int           colCount  = TableInfo.ColumnCount;
            DataTableInfo tableInfo = TableInfo;

            for (int i = 0; i < colCount; ++i)
            {
                if (tableInfo[i].DataType.IsIndexable)
                {
                    SelectableScheme ss = GetRootColumnScheme(i);
                    ss.Insert(rowNumber);
                }
            }
        }
Esempio n. 23
0
        internal DataColumnInfo(DataTableInfo tableInfo, string name, DataType type)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }

            this.tableInfo = tableInfo;
            this.name      = name;
            this.type      = type;
        }
Esempio n. 24
0
        ///<summary>
        ///</summary>
        ///<param name="database"></param>
        ///<param name="name"></param>
        ///<param name="fields"></param>
        public TemporaryTable(IDatabase database, String name, DataColumnInfo[] fields)
            : base(database)
        {
            tableStorage = new List<DataObject[]>();

            tableInfo = new DataTableInfo(new ObjectName(name));

            foreach (DataColumnInfo field in fields) {
                var newColumn = tableInfo.NewColumn(field.Name, field.DataType);
                newColumn.DefaultExpression = field.DefaultExpression;
                newColumn.IsNullable = field.IsNullable;
                tableInfo.AddColumn(newColumn);
            }
            tableInfo.IsReadOnly = true;
        }
        /// <summary>
        /// Constructs the source.
        /// </summary>
        /// <param name="caseInsensitive"></param>
        /// <param name="tableQuery"></param>
        /// <param name="uniqueName"></param>
        /// <param name="givenName"></param>
        /// <param name="rootName"></param>
        public FromTableDirectSource(bool caseInsensitive, ITableQueryInfo tableQuery, string uniqueName, ObjectName givenName, ObjectName rootName)
        {
            this.uniqueName = uniqueName;
            dataTableInfo = tableQuery.TableInfo;
            RootTableName = rootName;
            if (givenName != null) {
                GivenTableName = givenName;
            } else {
                GivenTableName = rootName;
            }

            // Is the database case insensitive?
            this.caseInsensitive = caseInsensitive;
            this.tableQuery = tableQuery;
        }
Esempio n. 26
0
        ///<summary>
        ///</summary>
        ///<param name="database"></param>
        ///<param name="name"></param>
        ///<param name="fields"></param>
        public TemporaryTable(IDatabase database, String name, DataColumnInfo[] fields)
            : base(database)
        {
            tableStorage = new List <DataObject[]>();

            tableInfo = new DataTableInfo(new ObjectName(name));

            foreach (DataColumnInfo field in fields)
            {
                var newColumn = tableInfo.NewColumn(field.Name, field.DataType);
                newColumn.DefaultExpression = field.DefaultExpression;
                newColumn.IsNullable        = field.IsNullable;
                tableInfo.AddColumn(newColumn);
            }
            tableInfo.IsReadOnly = true;
        }
Esempio n. 27
0
            public ITableQueryInfo GetTableQueryInfo(ObjectName tableName, ObjectName givenName)
            {
                DataTableInfo tableInfo = GetTableInfo(tableName);

                // If the table is aliased, set a new DataTableInfo with the given name
                if (givenName != null)
                {
                    var newTableInfo = new DataTableInfo(givenName.Clone());
                    for (int i = 0; i < tableInfo.ColumnCount; i++)
                    {
                        var columnInfo = tableInfo[i];
                        newTableInfo.AddColumn(columnInfo.Name, columnInfo.DataType, !columnInfo.IsNotNull);
                    }

                    newTableInfo.IsReadOnly = true;
                    tableInfo = newTableInfo;
                }

                return(new TableQueryInfo(this, tableInfo, tableName, givenName));
            }
Esempio n. 28
0
        /// <inheritdoc/>
        public override int FindFieldName(ObjectName v)
        {
            // Check this is the correct table first...
            ObjectName    tableName = v.Parent;
            DataTableInfo tableInfo = TableInfo;

            if (tableName != null && tableName.Equals(TableName))
            {
                // Look for the column name
                string colName = v.Name;
                int    size    = ColumnCount;
                for (int i = 0; i < size; ++i)
                {
                    DataColumnInfo col = tableInfo[i];
                    if (col.Name.Equals(colName))
                    {
                        return(i);
                    }
                }
            }
            return(-1);
        }
Esempio n. 29
0
        /// <summary>
        /// Helper function for initializing the variables in the joined table.
        /// </summary>
        /// <param name="tables"></param>
        protected virtual void Init(Table[] tables)
        {
            int tableCount = tables.Length;

            referenceList = tables;

            int colCount = ColumnCount;

            columnScheme = new SelectableScheme[colCount];

            vtTableInfo = new DataTableInfo(new ObjectName(null, "#VIRTUAL TABLE#"));

            // Generate look up tables for column_table and column_filter information

            columnTable  = new int[colCount];
            columnFilter = new int[colCount];
            int index = 0;

            for (int i = 0; i < referenceList.Length; ++i)
            {
                Table         curTable     = referenceList[i];
                DataTableInfo curTableInfo = curTable.TableInfo;
                int           refColCount  = curTable.ColumnCount;

                // For each column
                for (int n = 0; n < refColCount; ++n)
                {
                    columnFilter[index] = n;
                    columnTable[index]  = i;
                    ++index;

                    // Add this column to the data table info of this table.
                    vtTableInfo.AddColumn(curTableInfo[n].Clone());
                }
            }

            vtTableInfo.IsReadOnly = true;
        }
Esempio n. 30
0
        protected virtual void Init(DataTableInfo[] tableInfos)
        {
            // Generate look up tables for column_table and column_filter information
            int colCount = 0;

            for (int i = 0; i < tableInfos.Length; i++)
            {
                colCount += tableInfos[i].ColumnCount;
            }

            columnTable  = new int[colCount];
            columnFilter = new int[colCount];
            int index = 0;

            for (int i = 0; i < tableInfos.Length; ++i)
            {
                DataTableInfo curTableInfo = tableInfos[i];
                int           refColCount  = curTableInfo.ColumnCount;

                // For each column
                for (int n = 0; n < refColCount; ++n)
                {
                    columnFilter[index] = n;
                    columnTable[index]  = i;
                    ++index;

                    // Add this column to the data table info of this table.
                    var sourceColumn = curTableInfo[n];
                    var newColumn    = new DataColumnInfo(this, sourceColumn.Name, sourceColumn.DataType);
                    newColumn.DefaultExpression = sourceColumn.DefaultExpression;
                    newColumn.IsNullable        = sourceColumn.IsNullable;
                    AddColumn(newColumn);
                }
            }

            IsReadOnly = true;
        }
Esempio n. 31
0
        public void SetUp()
        {
            database = new TestDatabase();

            var tableInfo = new DataTableInfo("APP", "person");
            tableInfo.AddColumn("id", PrimitiveTypes.Numeric());
            tableInfo.AddColumn("first_name", PrimitiveTypes.String());
            tableInfo.AddColumn("last_name", PrimitiveTypes.String());
            tableInfo.AddColumn("age", PrimitiveTypes.Numeric());

            var table = database.CreateTable(tableInfo);

            long rowIndex = table.NewRow();
            table.SetValue(0, rowIndex, DataObject.Number(0));
            table.SetValue(1, rowIndex, new DataObject(PrimitiveTypes.String(), new StringObject("Antonello")));
            table.SetValue(2, rowIndex, new DataObject(PrimitiveTypes.String(), new StringObject("Provenzano")));
            table.SetValue(3, rowIndex, new DataObject(PrimitiveTypes.Numeric(), Number.FromInt32(32)));

            rowIndex = table.NewRow();
            table.SetValue(0, rowIndex, DataObject.Number(1));
            table.SetValue(1, rowIndex, DataObject.String("Mart"));
            table.SetValue(2, rowIndex, DataObject.String("Roosmaa"));
            table.SetValue(3, rowIndex, DataObject.Number(28));

            tableInfo = new DataTableInfo("APP", "lives");
            tableInfo.AddColumn("person_id", PrimitiveTypes.Numeric());
            tableInfo.AddColumn("city", PrimitiveTypes.String());
            tableInfo.AddColumn("country", PrimitiveTypes.String());
            table = database.CreateTable(tableInfo);

            rowIndex = table.NewRow();
            table.SetValue(0, rowIndex, DataObject.Number(0));
            table.SetValue(1, rowIndex, DataObject.String("Oslo"));
            table.SetValue(2, rowIndex, DataObject.String("Norway"));

            rowIndex = table.NewRow();
            table.SetValue(0, rowIndex, DataObject.Number(1));
            table.SetValue(1, rowIndex, DataObject.String("Tallinn"));
            table.SetValue(2, rowIndex, DataObject.String("Estonia"));

            tableInfo = new DataTableInfo("APP", "devices");
            tableInfo.AddColumn("id", PrimitiveTypes.Numeric());
            tableInfo.AddColumn("person_id", PrimitiveTypes.Numeric());
            tableInfo.AddColumn("device_name", PrimitiveTypes.String());
            tableInfo.AddColumn("os", PrimitiveTypes.String());
            tableInfo.AddColumn("date", PrimitiveTypes.Date());
            table = database.CreateTable(tableInfo);

            rowIndex = table.NewRow();
            table.SetValue(0, rowIndex, DataObject.Number(0));
            table.SetValue(1, rowIndex, DataObject.Number(0));
            table.SetValue(2, rowIndex, DataObject.String("Work Notebook"));
            table.SetValue(3, rowIndex, DataObject.String("Windows 8.1"));
            table.SetValue(4, rowIndex, DataObject.Now());

            rowIndex = table.NewRow();
            table.SetValue(0, rowIndex, DataObject.Number(1));
            table.SetValue(1, rowIndex, DataObject.Number(0));
            table.SetValue(2, rowIndex, DataObject.String("Tablet"));
            table.SetValue(3, rowIndex, DataObject.String("Android 4.4"));
            table.SetValue(4, rowIndex, DataObject.Now());

            rowIndex = table.NewRow();
            table.SetValue(0, rowIndex, DataObject.Number(2));
            table.SetValue(1, rowIndex, DataObject.Number(0));
            table.SetValue(2, rowIndex, DataObject.String("Other Notebook"));
            table.SetValue(3, rowIndex, DataObject.String("Ubuntu Linux"));
            table.SetValue(4, rowIndex, DataObject.Now());

            rowIndex = table.NewRow();
            table.SetValue(0, rowIndex, DataObject.Number(3));
            table.SetValue(1, rowIndex, DataObject.Number(1));
            table.SetValue(2, rowIndex, DataObject.String("Mac Work Notebook"));
            table.SetValue(3, rowIndex, DataObject.String("Mac OS X"));
            table.SetValue(4, rowIndex, DataObject.Now());

            rowIndex = table.NewRow();
            table.SetValue(0, rowIndex, DataObject.Number(4));
            table.SetValue(1, rowIndex, DataObject.Number(1));
            table.SetValue(2, rowIndex, DataObject.String("Tablet"));
            table.SetValue(3, rowIndex, DataObject.String("Android 4.2"));
            table.SetValue(4, rowIndex, DataObject.Now());
        }
Esempio n. 32
0
        public void SetUp()
        {
            database = new TestDatabase();

            var tableInfo = new DataTableInfo("APP", "person");

            tableInfo.AddColumn("id", PrimitiveTypes.Numeric());
            tableInfo.AddColumn("first_name", PrimitiveTypes.String());
            tableInfo.AddColumn("last_name", PrimitiveTypes.String());
            tableInfo.AddColumn("age", PrimitiveTypes.Numeric());

            var table = database.CreateTable(tableInfo);

            long rowIndex = table.NewRow();

            table.SetValue(0, rowIndex, DataObject.Number(0));
            table.SetValue(1, rowIndex, new DataObject(PrimitiveTypes.String(), new StringObject("Antonello")));
            table.SetValue(2, rowIndex, new DataObject(PrimitiveTypes.String(), new StringObject("Provenzano")));
            table.SetValue(3, rowIndex, new DataObject(PrimitiveTypes.Numeric(), Number.FromInt32(32)));

            rowIndex = table.NewRow();
            table.SetValue(0, rowIndex, DataObject.Number(1));
            table.SetValue(1, rowIndex, DataObject.String("Mart"));
            table.SetValue(2, rowIndex, DataObject.String("Roosmaa"));
            table.SetValue(3, rowIndex, DataObject.Number(28));

            tableInfo = new DataTableInfo("APP", "lives");
            tableInfo.AddColumn("person_id", PrimitiveTypes.Numeric());
            tableInfo.AddColumn("city", PrimitiveTypes.String());
            tableInfo.AddColumn("country", PrimitiveTypes.String());
            table = database.CreateTable(tableInfo);

            rowIndex = table.NewRow();
            table.SetValue(0, rowIndex, DataObject.Number(0));
            table.SetValue(1, rowIndex, DataObject.String("Oslo"));
            table.SetValue(2, rowIndex, DataObject.String("Norway"));

            rowIndex = table.NewRow();
            table.SetValue(0, rowIndex, DataObject.Number(1));
            table.SetValue(1, rowIndex, DataObject.String("Tallinn"));
            table.SetValue(2, rowIndex, DataObject.String("Estonia"));

            tableInfo = new DataTableInfo("APP", "devices");
            tableInfo.AddColumn("id", PrimitiveTypes.Numeric());
            tableInfo.AddColumn("person_id", PrimitiveTypes.Numeric());
            tableInfo.AddColumn("device_name", PrimitiveTypes.String());
            tableInfo.AddColumn("os", PrimitiveTypes.String());
            tableInfo.AddColumn("date", PrimitiveTypes.Date());
            table = database.CreateTable(tableInfo);

            rowIndex = table.NewRow();
            table.SetValue(0, rowIndex, DataObject.Number(0));
            table.SetValue(1, rowIndex, DataObject.Number(0));
            table.SetValue(2, rowIndex, DataObject.String("Work Notebook"));
            table.SetValue(3, rowIndex, DataObject.String("Windows 8.1"));
            table.SetValue(4, rowIndex, DataObject.Now());

            rowIndex = table.NewRow();
            table.SetValue(0, rowIndex, DataObject.Number(1));
            table.SetValue(1, rowIndex, DataObject.Number(0));
            table.SetValue(2, rowIndex, DataObject.String("Tablet"));
            table.SetValue(3, rowIndex, DataObject.String("Android 4.4"));
            table.SetValue(4, rowIndex, DataObject.Now());

            rowIndex = table.NewRow();
            table.SetValue(0, rowIndex, DataObject.Number(2));
            table.SetValue(1, rowIndex, DataObject.Number(0));
            table.SetValue(2, rowIndex, DataObject.String("Other Notebook"));
            table.SetValue(3, rowIndex, DataObject.String("Ubuntu Linux"));
            table.SetValue(4, rowIndex, DataObject.Now());

            rowIndex = table.NewRow();
            table.SetValue(0, rowIndex, DataObject.Number(3));
            table.SetValue(1, rowIndex, DataObject.Number(1));
            table.SetValue(2, rowIndex, DataObject.String("Mac Work Notebook"));
            table.SetValue(3, rowIndex, DataObject.String("Mac OS X"));
            table.SetValue(4, rowIndex, DataObject.Now());

            rowIndex = table.NewRow();
            table.SetValue(0, rowIndex, DataObject.Number(4));
            table.SetValue(1, rowIndex, DataObject.Number(1));
            table.SetValue(2, rowIndex, DataObject.String("Tablet"));
            table.SetValue(3, rowIndex, DataObject.String("Android 4.2"));
            table.SetValue(4, rowIndex, DataObject.Now());
        }
Esempio n. 33
0
 public TableQueryInfo(IDatabaseConnection conn, DataTableInfo tableInfo, ObjectName tableName, ObjectName aliasedAs)
 {
     this.conn = conn;
     this.tableInfo = tableInfo;
     this.aliasedAs = aliasedAs;
     this.tableName = tableName;
 }
Esempio n. 34
0
 public TestTable CreateTable(DataTableInfo tableInfo)
 {
     var table = new TestTable(tableInfo);
     tables[tableInfo.TableName] = table;
     return table;
 }
Esempio n. 35
0
 public ChildTableInfo(DataTableInfo parent)
     : base(parent.Name)
 {
     Parent = parent;
 }
Esempio n. 36
0
            public ITableQueryInfo GetTableQueryInfo(ObjectName tableName, ObjectName givenName)
            {
                DataTableInfo tableInfo = GetTableInfo(tableName);
                // If the table is aliased, set a new DataTableInfo with the given name
                if (givenName != null) {
                    var newTableInfo = new DataTableInfo(givenName.Clone());
                    for (int i = 0; i < tableInfo.ColumnCount; i++) {
                        var columnInfo = tableInfo[i];
                        newTableInfo.AddColumn(columnInfo.Name, columnInfo.DataType, !columnInfo.IsNotNull);
                    }

                    newTableInfo.IsReadOnly = true;
                    tableInfo = newTableInfo;
                }

                return new TableQueryInfo(this, tableInfo, tableName, givenName);
            }
Esempio n. 37
0
        protected virtual void Init(DataTableInfo[] tableInfos)
        {
            // Generate look up tables for column_table and column_filter information
            int colCount = 0;
            for (int i = 0; i < tableInfos.Length; i++) {
                colCount += tableInfos[i].ColumnCount;
            }

            columnTable = new int[colCount];
            columnFilter = new int[colCount];
            int index = 0;
            for (int i = 0; i < tableInfos.Length; ++i) {
                DataTableInfo curTableInfo = tableInfos[i];
                int refColCount = curTableInfo.ColumnCount;

                // For each column
                for (int n = 0; n < refColCount; ++n) {
                    columnFilter[index] = n;
                    columnTable[index] = i;
                    ++index;

                    // Add this column to the data table info of this table.
                    var sourceColumn = curTableInfo[n];
                    var newColumn = new DataColumnInfo(this, sourceColumn.Name, sourceColumn.DataType);
                    newColumn.DefaultExpression = sourceColumn.DefaultExpression;
                    newColumn.IsNullable = sourceColumn.IsNullable;
                    AddColumn(newColumn);
                }
            }

            IsReadOnly = true;
        }
Esempio n. 38
0
        /// <summary>
        /// Adds a column map into this table.
        /// </summary>
        /// <param name="mapping">The array containing a map to the column in 
        /// the parent table that we want the column number to reference.</param>
        /// <param name="aliases"></param>
        public void SetColumnMap(int[] mapping, ObjectName[] aliases)
        {
            reverse_column_map = new int[Parent.ColumnCount];
            for (int i = 0; i < reverse_column_map.Length; ++i) {
                reverse_column_map[i] = -1;
            }
            column_map = mapping;

            this.aliases = aliases;

            DataTableInfo parentInfo = Parent.TableInfo;
            subsetTableInfo = new DataTableInfo(parentInfo.TableName);

            for (int i = 0; i < mapping.Length; ++i) {
                int map_to = mapping[i];
                DataColumnInfo colInfo = Parent.GetColumnInfo(map_to).Clone();
                colInfo.Name = aliases[i].Name;
                subsetTableInfo.AddColumn(colInfo);
                reverse_column_map[map_to] = i;
            }

            subsetTableInfo.IsReadOnly = true;
        }
Esempio n. 39
0
 public TestTable(DataTableInfo tableInfo)
 {
     this.tableInfo = tableInfo;
     rows = new List<DataObject[]>();
 }
Esempio n. 40
0
 /// <summary>
 /// Constructs this <see cref="TemporaryTable"/> based on the 
 /// fields from the given <see cref="Table"/> object.
 /// </summary>
 /// <param name="name"></param>
 /// <param name="based_on"></param>
 public TemporaryTable(String name, Table based_on)
     : base(based_on.Database)
 {
     tableInfo = based_on.TableInfo.Clone(new ObjectName(null, name));
     tableInfo.IsReadOnly = true;
 }
Esempio n. 41
0
 /// <summary>
 /// Constructs this <see cref="TemporaryTable"/> based on the given 
 /// <see cref="Table"/> object.
 /// </summary>
 /// <param name="based_on"></param>
 public TemporaryTable(Table based_on)
     : base(based_on.Database)
 {
     tableInfo = based_on.TableInfo.Clone();
     tableInfo.IsReadOnly = true;
 }
Esempio n. 42
0
        public DataTableInfo Clone(ObjectName newTableName)
        {
            DataTableInfo clone = new DataTableInfo(newTableName);
            clone.tableTypeName = (string)tableTypeName.Clone();
            clone.columns = new List<DataColumnInfo>();
            foreach (DataColumnInfo column in columns) {
                clone.columns.Add(column.Clone());
            }

            return clone;
        }
Esempio n. 43
0
 /// <summary>
 /// Constructs this <see cref="TemporaryTable"/> based on the
 /// fields from the given <see cref="Table"/> object.
 /// </summary>
 /// <param name="name"></param>
 /// <param name="based_on"></param>
 public TemporaryTable(String name, Table based_on)
     : base(based_on.Database)
 {
     tableInfo            = based_on.TableInfo.Clone(new ObjectName(null, name));
     tableInfo.IsReadOnly = true;
 }
Esempio n. 44
0
        ///<summary>
        ///</summary>
        ///<param name="crossRefTable"></param>
        ///<param name="inExpList"></param>
        ///<param name="columnNames"></param>
        ///<param name="context"></param>
        public FunctionTable(Table crossRefTable, Expression[] inExpList, string[] columnNames, IQueryContext context)
            : base(context.Connection.Database)
        {
            // Make sure we are synchronized over the class.
            lock (typeof (FunctionTable)) {
                uniqueId = UniqueKeySeq;
                ++UniqueKeySeq;
            }
            uniqueId = (uniqueId & 0x0FFFFFFF) | 0x010000000;

            this.context = context;

            this.crossRefTable = crossRefTable;
            crResolver = crossRefTable.GetVariableResolver();
            crResolver.SetId = 0;

            // Create a DataTableInfo object for this function table.
            funTableInfo = new DataTableInfo(FunctionTableName);

            expList = new Expression[inExpList.Length];
            expInfo = new byte[inExpList.Length];

            // Create a new DataColumnInfo for each expression, and work out if the
            // expression is simple or not.
            for (int i = 0; i < inExpList.Length; ++i) {
                Expression expr = inExpList[i];
                // Examine the expression and determine if it is simple or not
                if (expr.IsConstant() && !expr.HasAggregateFunction(context)) {
                    // If expression is a constant, solve it
                    DataObject result = expr.Evaluate(null, null, context);
                    expr = Expression.Constant(result);
                    expList[i] = expr;
                    expInfo[i] = 1;
                } else {
                    // Otherwise must be dynamic
                    expList[i] = expr;
                    expInfo[i] = 0;
                }
                // Make the column info
                funTableInfo.AddColumn(columnNames[i], expr.ReturnType(crResolver, context));
            }

            // Make sure the table info isn't changed from this point on.
            funTableInfo.IsReadOnly = true;

            // Function tables are the size of the referring table.
            row_count = crossRefTable.RowCount;

            // Set schemes to 'blind search'.
            BlankSelectableSchemes(1);
        }
Esempio n. 45
0
 private void CallInit(DataTableInfo[] tableInfos)
 {
     Init(tableInfos);
 }
Esempio n. 46
0
 public ChildTableInfo(DataTableInfo parent)
     : base(parent.Name)
 {
     Parent = parent;
 }
Esempio n. 47
0
 public JoinedTableInfo(ObjectName name, DataTableInfo[] tableInfos)
     : base(name)
 {
     sourceInfos = tableInfos;
     CallInit(tableInfos);
 }
Esempio n. 48
0
 public TestTable(DataTableInfo tableInfo)
 {
     this.tableInfo = tableInfo;
     rows           = new List <DataObject[]>();
 }
Esempio n. 49
0
 /// <summary>
 /// Constructs this <see cref="TemporaryTable"/> based on the given
 /// <see cref="Table"/> object.
 /// </summary>
 /// <param name="based_on"></param>
 public TemporaryTable(Table based_on)
     : base(based_on.Database)
 {
     tableInfo            = based_on.TableInfo.Clone();
     tableInfo.IsReadOnly = true;
 }
Esempio n. 50
0
        /// <summary>
        /// Helper function for initializing the variables in the joined table.
        /// </summary>
        /// <param name="tables"></param>
        protected virtual void Init(Table[] tables)
        {
            int tableCount = tables.Length;
            referenceList = tables;

            int colCount = ColumnCount;
            columnScheme = new SelectableScheme[colCount];

            vtTableInfo = new DataTableInfo(new ObjectName(null, "#VIRTUAL TABLE#"));

            // Generate look up tables for column_table and column_filter information

            columnTable = new int[colCount];
            columnFilter = new int[colCount];
            int index = 0;
            for (int i = 0; i < referenceList.Length; ++i) {
                Table curTable = referenceList[i];
                DataTableInfo curTableInfo = curTable.TableInfo;
                int refColCount = curTable.ColumnCount;

                // For each column
                for (int n = 0; n < refColCount; ++n) {
                    columnFilter[index] = n;
                    columnTable[index] = i;
                    ++index;

                    // Add this column to the data table info of this table.
                    vtTableInfo.AddColumn(curTableInfo[n].Clone());
                }

            }

            vtTableInfo.IsReadOnly = true;
        }
Esempio n. 51
0
 /// <summary>
 /// Copies the object, excluding the columns and the constraints
 /// contained in it.
 /// </summary>
 /// <returns></returns>
 public DataTableInfo NoColumnClone()
 {
     DataTableInfo info = new DataTableInfo(tableName);
     info.tableTypeName = tableTypeName;
     return info;
 }