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)); }
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)); }
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)); }
internal override object Eval() { throw ExprException.EvalNoContext(); }
internal override object Eval() { // can not eval column without ROW value; throw ExprException.EvalNoContext(); }