If I navigate away from the main BO and come back, the ListView shows the correct customer. If I add a new record and call the requery method, the ListView show the proper customer. Only the delete is doing this. So, what am I doing wrong?
I assume that you are deleting the parent record. The BOs do not cascade the deletions to the child (by default). You need to clear out the child BO records that are no longer valid by either repopulating the BO, or clearing it out via the Clear method. Or...delete each of the records that are no longer valid. More than likely the cascading deletes have taken place on the server, so you just need to clear out the child BO to match the parent. I recommend doing this manually instead of allowing the deletions or child records to be automatically filtered (other issues that arise from there
)
MyBo.Clear()
or
'-- Delete all of the records that need to be deleted (this code would only delete a single record)
MyBo.DeleteCurrentRow(True)
'-- Update the BO so that it doesn't reflect any dirty changes. By doing this, you can make a change
' to the BO data and prevent it from trying to persist back to the server. Once called, the BO will no longer be in a
' dirty state.
MyBo.CurrentDataTable.AcceptChanges()