2

I have a strongly-typed dataset (VB.NET), using .NET Framework 2.0. Given a DataRow in a parent DataTable and a DataRelation, I need to find all related rows in the child DataTable that have a RowState = DataRowState.Deleted.

Unfortunately for me, DataRow.GetChildRows(DataRelation) does not include child rows that have a RowState of DataRowState.Deleted.

Currently I'm doing a table scan of the child table to find the deleted rows that match the criteria of the relation, but my tables have become too large for that to work. How can I get the deleted child rows with decent performance?

Tony Abrams
  • 4,505
  • 3
  • 25
  • 32
David Burson
  • 2,947
  • 7
  • 32
  • 55

2 Answers2

2

You can use DataSet.GetChanges and pass the DataRowState.Deleted parameter. It should return a DataSet that contains all the rows marked as deleted.

Tony Abrams
  • 4,505
  • 3
  • 25
  • 32
  • helpful info (I upvoted), but I have a large dataset (lots of tables) and am only interested in one specific table. table.getchanges would probably work, except I don't want a copy of the table - I want the actual datarows, since I'm performing an Update on them. – David Burson Dec 28 '10 at 15:16
1

solved this by using GetChildRows(relation, DataRowVersion.Original). Then, iterate through those rows and grab the ones with RowState = DataRowState.Deleted.

David Burson
  • 2,947
  • 7
  • 32
  • 55