Detect if an entity has been deleted in a transaction already

Posts   
 
    
scotru
User
Posts: 104
Joined: 16-Feb-2006
# Posted on: 27-Jan-2015 10:10:56   

Is there a way to determine if an entity has been deleted earlier in a transaction to avoid updating it? I have a transaction failing with: "During "a save action, an entity's update action failed." Because I've already deleted the entity. I'd like to check if the entity has been deleted in the transaction before adding the update to the transaction.

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 27-Jan-2015 22:22:46   

I recommend using Unit of Work

It executes the actions added to it in the following order: CallBacks for the PreEntityInsert slot, Inserts, CallBacks for the PreEntityUpdate slot, Updates, UpdateEntitiesDirectly calls, CallBacks for the PreEntityDelete slot, Deletes, CallBacks for the PostEntityDelete slot, DeleteEntitiesDirectly calls. This order can be too limited, for example if you first have to delete an entity before a new insert can take place because the entity to insert has the same value for a field with a unique constraint.

LLBLGen Pro lets you define entity oriented actions to be ordered in a different order.

scotru
User
Posts: 104
Joined: 16-Feb-2006
# Posted on: 27-Jan-2015 22:34:17   

That would indeed be a great solution. Sadly, I'm using an older version of Llblgen on a legacy codebase that doesn't support unit of work. Any way just to determine if a delete is pending on the entity in the transaction? I can easily determine if the entity is in the transaction--but can't seem to tell if it's being deleted.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 28-Jan-2015 07:11:02   
  • What 'older' LLBLGen version are you using?
  • Are you using Adapter or SelfServicing?
  • On what context do you need this? Don't you know by the flow of the code if some entity has already been deleted?
David Elizondo | LLBLGen Support Team