Hi all,
I have table "A" referenced by table "B", while table "B" is referenced by many other tables (1:n, m:n), and I want to delete all records from all tables eventually referencing table "A".
So far I found 2 ways to perform a recursive deletion.
1.
Fetching the "A" entity (including the prefetch definition for all referencing tables) and then delete each entity if it is not null and each collection if it is not empty:
IPrefetchPath2 pp = ........
adapter.FetchEntity(...., pp);
if(BEntity.C != null)
adapter.DeleteEntity(BEntity.C);
.
.
.
if(BEntity.Z != null)
adapter.DeleteEntity(BEntity.Z);
adapter.DeleteEntity(BEntity);
adapter.DeleteEntity(AEntity);
Something like that...
I don't like this solution, but I would like to get comments for that.
2.
Using UnitOfWork2 - but here I have a problem. I figured out that I need to define for each AddDeleteEntitiesDirectlyCall an IRelationPredicateBucket, and it is a lot of work. Isn't there an elegant way to do this?