private void MarkModifiedRows(TableChanges[] bitMatrix, DataRowState rowStates)
{
// for every table, every row & every relation find the modified rows and for non-deleted rows, their parents
for (int tableIndex = 0; tableIndex < bitMatrix.Length; ++tableIndex)
{
DataRowCollection rows = Tables[tableIndex].Rows;
int rowCount = rows.Count;
for (int rowIndex = 0; rowIndex < rowCount; ++rowIndex)
{
DataRow row = rows[rowIndex];
DataRowState rowState = row.RowState;
Debug.Assert(DataRowState.Added == rowState ||
DataRowState.Deleted == rowState ||
DataRowState.Modified == rowState ||
DataRowState.Unchanged == rowState,
"unexpected DataRowState");
// if bit not already set and row is modified
if ((0 != (rowStates & rowState)) && !bitMatrix[tableIndex][rowIndex])
{
bitMatrix[tableIndex][rowIndex] = true;
if (DataRowState.Deleted != rowState)
{
MarkRelatedRowsAsModified(bitMatrix, row);
}
}
}
}
}