I have a problem rejecting a DataSet with self-related tables.
First I insert a parent row and a child row in a table. Then I call RejectChanges method from the table object or the same method from the DataSet. The RejectChagnes method throws RowNotInTableException.
This is the code to demostrate this (TestRejectChanges.zip):
DataSet dataSet = new DataSet();
//Parent row
DataSet.TABLERow parentRowOverDataSet = dataSet.TABLE.AddTABLERow(1, "Parent", null);
//Child row
dataSet.TABLE.AddTABLERow(2, "Child", parentRowOverDataSet);
//This line crash because the child row is detached before Rolback (in RejectChanges method code)
dataSet.TABLE.RejectChanges();
//Also crash
//foreach (DataSet.TABLERow row in dataSet.TABLE.ToList())
//{
// row.RejectChanges();
//}
//Also crash
//dataSet.RejectChanges();
I tryed to override RejectChanges of DataTable but this method is not virtual. Is there any way to do this using RejectChanges of DataSet?