Removing unsaved entities from object graph

Posts   
 
    
stoney77
User
Posts: 10
Joined: 18-Jul-2008
# Posted on: 22-Jun-2011 10:21:38   

We have a windows application utilising LLBLGEN 3.1 entities in the Self Service Model.

If we want to create a new instance of an entity we new up the entity and pass it to a UI to edit and relate properties to other entities within the system. If the user finally clicks save everything works well, but if they choose not to save we would like to remove all trace of the entity. We cant call delete as it hasnt been saved to the database. If we just leave it there it could get inadvertantly saved when saving a related entity, what is the best way to remove this entity from the object graph?

Thanks, Stephen

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 22-Jun-2011 11:44:39   

I'm not sure whether your problem is how to Remove an entitiy from the root collection of your graph or how to find that specific entity.

stoney77
User
Posts: 10
Joined: 18-Jul-2008
# Posted on: 22-Jun-2011 14:45:14   

I dont need to find the entity, I have a reference to it. The problem is it may have been added to the collections of 5-6 other related entities. So I could manually go through each related collection and emove the entity, but it is quite manual and I need to repeat this process for numerous other types of entity within the application.

Is there anyway for llblgen to do this for me? or should I use an alternate approach.

Thanks, Stephen

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 22-Jun-2011 16:19:54   

You should have a rountine that dereference this entity from its related entities, and then remove it from the main collection. You don't have to prase the graph for references of this entity, it's enough to just use that entity's related collections/navigators and de-reference them, this should automatically de-reference the entity from these related entities' collections/navigators.

P.S. r to use a context to guarantee unique instances of each entity.