开发者

.net dataset how to get deleted child rows

开发者 https://www.devze.com 2023-02-01 22:18 出处:网络
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

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 row开发者_运维知识库s with decent performance?


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消