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));
}