Clone() returns an identical clone. It must do this in fact, or the data portal will fail.
It sounds like you want a Copy() method that creates a new set of objects based on the original (but not the same).
In the past I've recommended people override the cloning behavior to make this happen, but now that would be a bad idea, because the 3.5 data portal will clone your objects by default in some cases, and it expects a real clone (100% copy).
So what you should do is create a Copy() method that creates a clone and then manipulates the clone as required. This may mean implementing extra methods on your objects to allow the Copy() method to reset your child states:
Public Function Copy() As Client
Dim tmp As Client = Me.Clone()
tmp.FixUpAfterCopy()
End Function
Private Sub FixUpAfterCopy()
MarkNew()
mChildList.FixUpAfterCopy()
End Sub
---- then in ChildList ----
Friend Sub FixUpAfterCopy()
For Each item As Orders In DeletedList
item.FixUpAfterCopy()
Next
For Each item As Orders In Me
item.FixUpAfterCopy()
Next
End Sub
---- then in Orders ----
Friend Sub FixUpAfterCopy()
MarkNew()
End Sub
Copyright (c) Marimer LLC