You can implement a base class like this that overrides the Save method by invoking the clone first before actually saving the object. You can derive your business objects that needs to be saved "automagically" from this class. There is also a collection class that does save after each edit. Please see EditableRootListBase.
Imports
CslaPublic
MustInherit Class ClonedSavingBusinessBase(Of T As Csla.BusinessBase(Of T)) Inherits BusinessBase(Of T) Public Overrides Function Save() As T Dim cloneT As T = Clone() Return cloneT.Save() End FunctionEnd
ClassAlso be sure to check the newer versions of CSLA as Rocky has added AutoClone to the DataPortal. I think it is false for now by default and you can changeit tot True. In the next version he is going to make it True by Default because it should have always been that way.
Joe
On a related note, beware of EditableRootListBase unless you have the new AutoClone feature turned *on*.
I found that otherwise, ERLB would clone objects that weren't even dirty, perhaps when leaving a grid to edit the same item on a property sheet. At that point, the object in the ERLB and object on the form were two different objects.
With AutoClone, the object doesn't get cloned/saved unless it is dirty. Much better.
Copyright (c) Marimer LLC