Copying root businessobjectsCopying root businessobjects
Old forum URL: forums.lhotka.net/forums/t/1562.aspx
RRorije posted on Monday, October 23, 2006
I have implemented a copy function that copies a businessobject to a new businessobject with the same values. I did this in the following way:
Public Shared Function Copy<BO>(ByVal oldBo As <BO>) As <BO>
Dim newBO As <BO>
newBO = DirectCast(oldBO.Clone, <BO>)
newBO.MarkNew()
Return newBO
End Function
To ensure that child collections are also marked new, I have to call MarkNew on all child objects. This can be done by overriding MarkNew. My problem is that this is not possible without loosening the constraints on MarkNew and implementing a method on the child collection to mark all its children New.
I wonder how you do this, or whether I missed something completely obvious.
Copyright (c) Marimer LLC