ApplyEdit() is Saving my business object in new version of CSLA

ApplyEdit() is Saving my business object in new version of CSLA

Old forum URL: forums.lhotka.net/forums/t/1466.aspx


kreed posted on Thursday, October 12, 2006

We recently updated our project to the new version of CSLA and I have noticed that objects are being saved to the database when ApplyEdit() is called.  This wasn't how it worked in the older version.  In our case, we specifically don't want objects to be saved until we directly call Save() on the object.  Has the purpose of ApplyEdit() changed in the new version of CSLA?  Has something else taken its place as far as its old purpose?  Any insight would be greatly appreciated.  Thanks.

ajj3085 replied on Thursday, October 12, 2006

Well that's something that must be happening because of your code, because ApplyEdit should not be saving your objects.  Its purpose hasn't changed in Csla 2.

Set a break point in your Save and check the stack trace.

HTH
Andy

RockfordLhotka replied on Thursday, October 12, 2006

The only exception to this is the new EditableRootListBase in version 2.1 - which does automatically save objects as the user moves from row to row in a datagridview (or similar control).

But otherwise no, ApplyEdit() doesn't save objects - you must explicitly call Save().

kreed replied on Thursday, October 12, 2006

OK.  That is the case where I am seeing this happening.  Is there a built in way to override this behavior by any chance?  Thanks so much for your help.

RockfordLhotka replied on Thursday, October 12, 2006

To avoid this behavior, don't use EditableRootListBase. Use BusinessListBase, which does require you to call Save() on the root object to save all the objects in the collection.

ajj3085 replied on Thursday, October 12, 2006

Ahh, sorry.  I had assumed you upgraded, but didn't think you would have switched to using that superclass.

kreed replied on Thursday, October 12, 2006

Gotcha.  Thanks so much.

Copyright (c) Marimer LLC