mark for deletion

Posts   
 
    
Elk
User
Posts: 2
Joined: 04-Feb-2010
# Posted on: 04-Feb-2010 10:07:13   

Hello,

When I add new entities to a collection of sub entities connected to a parent entity and then recursively save the parent entity - new entities are created in the persistent storage.

However if I'll now call clear on the collection and again save the parent entity recursively, the entities aren't removed from the persistent storage. Actually even the connection by FK to the Parent entity isn't removed, so basically nothing happens.

Moreover it seems that deletion on an entity is an operation equal to save and immediately preforms changes, instead of being equal to create/update.

Is there a behavior like Datasets deletion ? Where you mark for deletion and only calling save on the entity will performs the delete from storage ?

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 04-Feb-2010 10:19:40   
Elk
User
Posts: 2
Joined: 04-Feb-2010
# Posted on: 04-Feb-2010 12:46:39   
  1. Is there a way to sign to llbl that it should always track entities removal ? Or every time I fetch an entity I need to go over all its relations and set a tracker ?

  2. If there are trackers of deleted entities, will recursive save delete the entities or before save I again need to go over all the relations and call deleteMulti on each tracker ?

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 04-Feb-2010 21:30:23   

1) Unfortunatly not. There are several ways you could do this though, either by modifiing the template, tapping into the entity OnInitialise event, or creating your own entity factory to create the entities with the trackers already created. To be honest though, I've never found it a massive problem creating them as and when they are needed as you usually know when an entity will be in a situation where its children need to be deleted.

2) Recursive save will not delete the entities in the trackers. You can either delete them yourself using .DeleteMulti, or pass the collections to a UnitOfWork using .AddCollectionForDelete to have all of the database operations performed in one go.

Matt