UnitOfWork Order of deletes

Posts   
 
    
Posts: 2
Joined: 07-Jan-2005
# Posted on: 07-Jan-2005 06:50:38   

I am trying to use the UnitOfWork, and am having difficulties in deletions that are added to the UnitOfWork.

My problem is that I am adding a collection of Entities that I want deleted, but for these items to be deleted a single Entity that is in the UnitOfWork needs to be deleted first, otherwise the database will lose integrity. I have the neccessary data structure in the database so the delete fails.

Is there anyway that the order of deletions can be set?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 07-Jan-2005 09:15:49   

No there isn't at the moment, you have to specify the deletes in the right order. This is due to the lack of support for cascading deletes (recursive deletes ala recursive saves) in the current llblgen pro code. See the unit of work as a collector of actions you'd otherwise execute directly. Then too you have to call the delete methods in the right order.

Frans Bouma | Lead developer LLBLGen Pro
Posts: 2
Joined: 07-Jan-2005
# Posted on: 07-Jan-2005 18:10:12   

Otis wrote:

No there isn't at the moment, you have to specify the deletes in the right order. This is due to the lack of support for cascading deletes (recursive deletes ala recursive saves) in the current llblgen pro code. See the unit of work as a collector of actions you'd otherwise execute directly. Then too you have to call the delete methods in the right order.

I was actually adding the EntityCollection to the UnitOfWork first, and then the Entity, but the Entity was still trying to delete itself first.

I ended up fixing it by iterating over the collection and adding each Entity to the UnitOfWork and then the delete went through in the right order.

Thanks...

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 07-Jan-2005 19:19:59   

Yes entity deletes are done first, then deletes using a collection.

Frans Bouma | Lead developer LLBLGen Pro