MarkOld After ChildUpdate

MarkOld After ChildUpdate

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


RealMrTea posted on Tuesday, April 08, 2008

In version 3.5 there is a line I am not to clear about.  I have the normal object Order with a collection (OrderDetails) of OrderDetail objects.  I want to delete an OrderDetail object from the OrderDetails collection so I MarkDeleted and I have it setup to be deleted.  In the ChildDataPortal it calls "Child_DeleteSelf" and when it returns it says if(target!=null) target.MarkOld(); 

This call to MarkOld sets the deletedOrderDetail object to old which overwrites the IsDeleted property to false.

My question is why after an object is deleted would you call MarkNew()?  It doesn't make sense to me.  I understand in the case of an update or insert...but not in the case of a delete.

I should mention that I am delaying the deletion of the object so that it can still appear in my grid as red and that is why I am not just removing it from the list.  I will also throw in that I am doing soft deletes.

Any words of advice,

Eric

RealMrTea replied on Thursday, April 17, 2008

After re-reading through the CSLA books I really found the answer as to why.  Any objects who doesn't have an ID in the database is considered new.  The part I don't like about this is that my implementation of this uses soft deletes so technicaly the above statement is not true.  I later want to look at the object and see the IsDeleted state so I can do other things with it (Remove it from a list, etc...) but the flag is (in my mind set) inscorrect.

My solution is to provide my own Deleted flag on each object that doesn't get set by DataPortal which I can look through as needed.

Copyright (c) Marimer LLC