Exemple #1
0
 /// <include file='doc\DataColumnCollection.uex' path='docs/doc[@for="DataColumnCollection.OnCollectionChanged"]/*' />
 /// <devdoc>
 ///    <para>
 ///       Raises the <see cref='System.Data.DataColumnCollection.OnCollectionChanged'/> event.
 ///    </para>
 /// </devdoc>
 protected virtual void OnCollectionChanged(CollectionChangeEventArgs ccevent)
 {
     table.UpdatePropertyDescriptorCollectionCache();
     if (!table.SchemaLoading && !table.fInitInProgress)
     {
         columnQueue = new ColumnQueue(table, columnQueue);
     }
     if (onCollectionChangedDelegate != null)
     {
         onCollectionChangedDelegate(this, ccevent);
     }
 }
Exemple #2
0
        internal ColumnQueue(DataTable table, ColumnQueue old)
        {
            Debug.Assert(table != null, "ColumnQueue: Invalid parameter (table == null)");
            Debug.Assert(table.TableName != null, "ColumnQueue: Invalid parameter Where is the table name?");

#if DEBUG
            if (CompModSwitches.DataExpression.TraceVerbose)
            {
                Debug.WriteLine("Create ColumnQueue for table " + table.TableName);
            }
#endif
            DataColumn[] allcolumns = new DataColumn[table.Columns.Count];
            table.Columns.CopyTo(allcolumns, 0);

            this.owner = table;

            InitQueue(this, allcolumns);

#if DEBUG
            if (CompModSwitches.DataExpression.TraceVerbose)
            {
                Debug.WriteLine("we have " + columnCount.ToString() + " column in the column queue");
            }
            //for (int i = 0; i < columnCount; i++) {
            //UNDONE : Debug.WriteLineIf("DataExpression", i.ToString() + ", " + columns[i].ColumnName);
            //}
#endif

            // scan the old evaluation queue for the external dependencies,
            // and add then at the end of the new evaluation queue.

            if (old != null && old.columnCount != 0)
            {
                for (int i = 0; i < old.columnCount; i++)
                {
                    if (old.columns[i] == null)
                    {
                        break;
                    }
                    if (old.columns[i].Table != null && old.columns[i].Table != owner)
                    {
                        AddColumn(old.columns[i]);
                    }
                }
            }
        }
Exemple #3
0
 internal void RefreshComputedColumns(DataColumn start)
 {
     columnQueue = new ColumnQueue(table, columnQueue);
     CalculateExpressions(columnQueue.columns, columnQueue.columnCount, start);
 }
Exemple #4
0
        private static void InitQueue(ColumnQueue queue, DataColumn[] cols)
        {
#if DEBUG
            if (CompModSwitches.DataExpression.TraceVerbose)
            {
                Debug.WriteLine("InitQueue");
            }
            if (CompModSwitches.DataExpression.TraceVerbose)
            {
                Debug.WriteLine("Building columnQueue, current size is " + queue.columns.Length.ToString() + " next element " + queue.columnCount.ToString());
                Debug.WriteLine("Dependencies..");
            }
            //for (int i = 0; i < cols.Length; i++) {
            //UNDONE : Debug.WriteLineIf("DataExpression", cols[i].ColumnName);
            //}
#endif

            for (int i = 0; i < cols.Length; i++)
            {
                DataColumn column = cols[i];

                // for all Computed columns, get the list of the dependencies

                if (column.Computed)
                {
#if DEBUG
                    if (CompModSwitches.DataExpression.TraceVerbose)
                    {
                        Debug.WriteLine("Looking at the expression column " + column.ColumnName + "=" + column.Expression);
                    }
#endif

                    DataColumn[] dependency = column.DataExpression.GetDependency();

                    int j;
                    // look through the expression dependencies in search of "foreign" columns

                    for (j = 0; j < dependency.Length; j++)
                    {
                        if (dependency[j].Table != queue.owner)
                        {
                            dependency[j].Table.Columns.ColumnQueue.AddColumn(column);
                        }
                    }

                    InitQueue(queue, dependency);

                    // add the current column to the queue, if its not there already

#if DEBUG
                    if (CompModSwitches.DataExpression.TraceVerbose)
                    {
                        Debug.WriteLine("InitQueue: Check if column [" + column.ColumnName + "] already in the list.");
                    }
#endif
                    for (j = 0; j < queue.columnCount; j++)
                    {
                        if (queue.columns[j] == column)
                        {
#if DEBUG
                            if (CompModSwitches.DataExpression.TraceVerbose)
                            {
                                Debug.WriteLine("Found column [" + column.ColumnName + "] in pos " + j.ToString());
                            }
#endif
                            break;
                        }
                    }
                    if (j >= queue.columnCount)
                    {
#if DEBUG
                        if (CompModSwitches.DataExpression.TraceVerbose)
                        {
                            Debug.WriteLine("Add column [" + column.ColumnName + "], columns = " + queue.columnCount.ToString());
                        }
#endif
                        queue.AddColumn(column);
#if DEBUG
                        if (CompModSwitches.DataExpression.TraceVerbose)
                        {
                            Debug.WriteLine("And now we have columns = " + queue.columnCount.ToString());
                        }
#endif
                    }
                }
#if DEBUG
                else if (CompModSwitches.DataExpression.TraceVerbose)
                {
                    Debug.WriteLine("not computed column " + column.ColumnName);
                }
#endif
            }
        }