Foreign keys

Posts   
 
    
Phil
User
Posts: 9
Joined: 01-Apr-2005
# Posted on: 12-Apr-2005 13:12:17   

This is probably a real newbie question, but what the hey.

I want to delete an entity, but it's joined to other entities via foreign key. What I'd like to do is for the entity to also delete it's related entities. Is this possible?

Thanks for any help you can give.

Phil.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 12-Apr-2005 13:32:10   

You've to delete the entities in the right order, there is no cascading/recursive delete implemented, because deletes are irreversable, and should be done with care.

The current UnitOfWork objects don't sort entities to delete correctly, in 1.0.2004.2 (now in beta) this will be fixed soon.

Frans Bouma | Lead developer LLBLGen Pro
arschr
User
Posts: 894
Joined: 14-Dec-2003
# Posted on: 12-Apr-2005 15:20:59   

Or (at least in SQLServer) you can set cascading deletes in the db. But that also should be used with care.

Phil
User
Posts: 9
Joined: 01-Apr-2005
# Posted on: 12-Apr-2005 16:13:49   

Thanks for your help chaps.

It'd be useful to have some kind of facility to load all the fk's and do a delete all the way down the chain, albeit dangerous. simple_smile