AggregateUnbound() 공개 정적인 메소드

public static AggregateUnbound ( string expr ) : Exception
expr string
리턴 System.Exception
예제 #1
0
        internal override object Eval(DataRow row, DataRowVersion version)
        {
            if (_childTable == null)
            {
                throw ExprException.AggregateUnbound(ToString());
            }

            DataRow[] rows;

            if (_local)
            {
                rows = new DataRow[_childTable.Rows.Count];
                _childTable.Rows.CopyTo(rows, 0);
            }
            else
            {
                if (row == null)
                {
                    throw ExprException.EvalNoContext();
                }
                if (_relation == null)
                {
                    throw ExprException.AggregateUnbound(ToString());
                }
                rows = row.GetChildRows(_relation, version);
            }

            int[] records;
            if (version == DataRowVersion.Proposed)
            {
                version = DataRowVersion.Default;
            }

            List <int> recordList = new List <int>();

            for (int i = 0; i < rows.Length; i++)
            {
                if (rows[i].RowState == DataRowState.Deleted)
                {
                    if (DataRowAction.Rollback != rows[i]._action)
                    {
                        continue;
                    }
                    Debug.Assert(DataRowVersion.Original == version, "wrong version");
                    version = DataRowVersion.Original;
                }
                else if ((DataRowAction.Rollback == rows[i]._action) && (rows[i].RowState == DataRowState.Added))
                {
                    continue;
                }
                if (version == DataRowVersion.Original && rows[i]._oldRecord == -1)
                {
                    continue;
                }
                recordList.Add(rows[i].GetRecordFromVersion(version));
            }
            records = recordList.ToArray();

            return(_column.GetAggregateValue(records, _type));
        }
예제 #2
0
        internal override void Bind(DataTable table, List <DataColumn> list)
        {
            base.BindTable(table);
            if (table == null)
            {
                throw ExprException.AggregateUnbound(this.ToString());
            }
            if (this.local)
            {
                this.relation = null;
            }
            else
            {
                DataRelationCollection childRelations = table.ChildRelations;
                if (this.relationName == null)
                {
                    if (childRelations.Count > 1)
                    {
                        throw ExprException.UnresolvedRelation(table.TableName, this.ToString());
                    }
                    if (childRelations.Count != 1)
                    {
                        throw ExprException.AggregateUnbound(this.ToString());
                    }
                    this.relation = childRelations[0];
                }
                else
                {
                    this.relation = childRelations[this.relationName];
                }
            }
            this.childTable = (this.relation == null) ? table : this.relation.ChildTable;
            this.column     = this.childTable.Columns[this.columnName];
            if (this.column == null)
            {
                throw ExprException.UnboundName(this.columnName);
            }
            int num = 0;

            while (num < list.Count)
            {
                DataColumn column = list[num];
                if (this.column == column)
                {
                    break;
                }
                num++;
            }
            if (num >= list.Count)
            {
                list.Add(this.column);
            }
            Bind(this.relation, list);
        }
예제 #3
0
 // Helper for the DataTable.Compute method
 internal override object Eval(int[] records)
 {
     if (_childTable == null)
     {
         throw ExprException.AggregateUnbound(ToString());
     }
     if (!_local)
     {
         throw ExprException.ComputeNotAggregate(ToString());
     }
     return(_column.GetAggregateValue(records, _type));
 }
예제 #4
0
        internal override object Eval(DataRow row, DataRowVersion version)
        {
#if DEBUG
            if (CompModSwitches.AggregateNode.TraceVerbose)
            {
                Debug.WriteLine("Eval " + this.ToString() + ", version " + version.ToString());
            }
#endif
            if (table == null)
            {
                throw ExprException.AggregateUnbound(this.ToString());
            }

            DataRow[] rows;

            if (local)
            {
                rows = new DataRow[table.Rows.Count];
                table.Rows.CopyTo(rows, 0);
            }
            else
            {
                if (row == null)
                {
                    throw ExprException.EvalNoContext();
                }
                if (relation == null)
                {
                    throw ExprException.AggregateUnbound(this.ToString());
                }
                rows = row.GetChildRows(relation, version);
            }
#if DEBUG
            if (CompModSwitches.AggregateNode.TraceVerbose)
            {
                Debug.WriteLine("Eval " + this.ToString() + ", # of Rows: " + rows.Length.ToString());
            }
#endif

            int[] records;

            if (version == DataRowVersion.Proposed)
            {
                version = DataRowVersion.Default;
            }

            records = new int[rows.Length];
            for (int i = 0; i < rows.Length; i++)
            {
                records[i] = rows[i].GetRecordFromVersion(version);
            }
            return(column.GetAggregateValue(records, type));
        }
예제 #5
0
        internal override object Eval(DataRow row, DataRowVersion version)
        {
            DataRow[] childRows;
            if (this.childTable == null)
            {
                throw ExprException.AggregateUnbound(this.ToString());
            }
            if (this.local)
            {
                childRows = new DataRow[this.childTable.Rows.Count];
                this.childTable.Rows.CopyTo(childRows, 0);
            }
            else
            {
                if (row == null)
                {
                    throw ExprException.EvalNoContext();
                }
                if (this.relation == null)
                {
                    throw ExprException.AggregateUnbound(this.ToString());
                }
                childRows = row.GetChildRows(this.relation, version);
            }
            if (version == DataRowVersion.Proposed)
            {
                version = DataRowVersion.Default;
            }
            List <int> list = new List <int>();

            for (int i = 0; i < childRows.Length; i++)
            {
                if (childRows[i].RowState == DataRowState.Deleted)
                {
                    if (DataRowAction.Rollback != childRows[i]._action)
                    {
                        continue;
                    }
                    version = DataRowVersion.Original;
                }
                else if ((DataRowAction.Rollback == childRows[i]._action) && (childRows[i].RowState == DataRowState.Added))
                {
                    continue;
                }
                if ((version != DataRowVersion.Original) || (childRows[i].oldRecord != -1))
                {
                    list.Add(childRows[i].GetRecordFromVersion(version));
                }
            }
            int[] records = list.ToArray();
            return(this.column.GetAggregateValue(records, this.type));
        }
예제 #6
0
        // Helper for the DataTable.Compute method
        internal override object Eval(int[] records)
        {
#if DEBUG
            if (CompModSwitches.AggregateNode.TraceVerbose)
            {
                Debug.WriteLine("Eval " + this.ToString());
            }
#endif
            if (table == null)
            {
                throw ExprException.AggregateUnbound(this.ToString());
            }
            if (!local)
            {
                throw ExprException.ComputeNotAggregate(this.ToString());
            }
            return(column.GetAggregateValue(records, type));
        }
예제 #7
0
        internal override void Bind(DataTable table, List <DataColumn> list)
        {
            BindTable(table);
            if (table == null)
            {
                throw ExprException.AggregateUnbound(ToString());
            }

            if (_local)
            {
                _relation = null;
            }
            else
            {
                DataRelationCollection relations;
                relations = table.ChildRelations;

                if (_relationName == null)
                {
                    // must have one and only one relation

                    if (relations.Count > 1)
                    {
                        throw ExprException.UnresolvedRelation(table.TableName, ToString());
                    }
                    if (relations.Count == 1)
                    {
                        _relation = relations[0];
                    }
                    else
                    {
                        throw ExprException.AggregateUnbound(ToString());
                    }
                }
                else
                {
                    _relation = relations[_relationName];
                }
            }

            _childTable = (_relation == null) ? table : _relation.ChildTable;

            _column = _childTable.Columns[_columnName];

            if (_column == null)
            {
                throw ExprException.UnboundName(_columnName);
            }

            // add column to the dependency list, do not add duplicate columns

            Debug.Assert(_column != null, "Failed to bind column " + _columnName);

            int i;

            for (i = 0; i < list.Count; i++)
            {
                // walk the list, check if the current column already on the list
                DataColumn dataColumn = list[i];
                if (_column == dataColumn)
                {
                    break;
                }
            }
            if (i >= list.Count)
            {
                list.Add(_column);
            }

            AggregateNode.Bind(_relation, list);
        }
예제 #8
0
        internal override void Bind(DataTable table, List <DataColumn> list)
        {
            BindTable(table);
            if (table == null)
            {
                throw ExprException.AggregateUnbound(this.ToString());
            }

            if (local)
            {
                relation = null;
            }
            else
            {
                DataRelationCollection relations;
                relations = table.ChildRelations;

                if (relationName == null)
                {
                    // must have one and only one relation

                    if (relations.Count > 1)
                    {
                        throw ExprException.UnresolvedRelation(table.TableName, this.ToString());
                    }
                    if (relations.Count == 1)
                    {
                        relation = relations[0];
                    }
                    else
                    {
                        throw ExprException.AggregateUnbound(this.ToString());
                    }
                }
                else
                {
                    relation = relations[relationName];
                }
            }

            childTable = (relation == null) ? table : relation.ChildTable;

            this.column = childTable.Columns[columnName];

            if (column == null)
            {
                throw ExprException.UnboundName(columnName);
            }

            // add column to the dependency list, do not add duplicate columns

            Debug.Assert(column != null, "Failed to bind column " + columnName);

            int i;

            for (i = 0; i < list.Count; i++)
            {
                // walk the list, check if the current column already on the list
                DataColumn dataColumn = (DataColumn)list[i];
                if (column == dataColumn)
                {
                    break;
                }
            }
            if (i >= list.Count)
            {
                list.Add(column);
            }

            // SQLBU 383715: Staleness of computed values in expression column as the relationship end columns are not being added to the dependent column list.
            AggregateNode.Bind(relation, list);
        }
예제 #9
0
        internal override void Bind(DataTable table, ArrayList list)
        {
#if DEBUG
            if (CompModSwitches.AggregateNode.TraceVerbose)
            {
                Debug.WriteLine("Binding Aggregate expression " + this.ToString());
            }
#endif
            if (table == null)
            {
                throw ExprException.AggregateUnbound(this.ToString());
            }

#if DEBUG
            if (CompModSwitches.AggregateNode.TraceVerbose)
            {
                Debug.WriteLine("in table " + table.TableName);
            }
#endif
            if (local)
            {
                relation = null;
            }
            else
            {
                DataRelationCollection relations;
                relations = table.ChildRelations;

                if (relationName == null)
                {
                    // must have one and only one relation

                    if (relations.Count > 1)
                    {
                        throw ExprException.UnresolvedRelation(table.TableName, this.ToString());
                    }
                    if (relations.Count == 1)
                    {
                        relation = relations[0];
                    }
                    else
                    {
                        throw ExprException.AggregateUnbound(this.ToString());
                    }
                }
                else
                {
                    relation = relations[relationName];
                }
                Debug.Assert(relation != null, String.Format(Res.GetString(Res.Expr_AggregateUnbound), this.ToString()));
            }

            DataTable childTable = (relation == null) ? table : relation.ChildTable;
            this.table = childTable;

            this.column = childTable.Columns[columnName];

            if (column == null)
            {
                throw ExprException.UnboundName(columnName);
            }

            // add column to the dependency list, do not add duplicate columns

            Debug.Assert(column != null, "Failed to bind column " + columnName);

            int i;
            for (i = 0; i < list.Count; i++)
            {
                // walk the list, check if the current column already on the list
                DataColumn dataColumn = (DataColumn)list[i];
                if (column == dataColumn)
                {
                    break;
                }
            }
            if (i >= list.Count)
            {
                list.Add(column);
            }

            //UNDONE : Debug.WriteLineIf("AggregateNode", this.ToString() + " bound");
        }