Hello,
I'm new to LLBLGenPro and I would like to know what is the best way to delete an entity and its related entities.
My case follows:
I have a CabinetEntity and a DoorEntity and a m:n relation between them realised in the db by an intermediate entity CabinetsDoorsEntity. Now, when I try to delete a CabinetEntity I get stoped by the relation to the CabinetsDoorsEntity - cause it is referenced there. Likewise if I try to delete the DoorEntity, I can't - it is also refrenced in the PK of the CabinetsDoorsEntity. How can I specify that when I delete a Cabinet I also want all the records referencing that cabinet in CabinetsDoors to be deleted?
I'm using adapter mode...
using (DataAccessAdapter da = new DataAccessAdapter(true))
{
EntityCollection<CabinetsEntity> toDel = new EntityCollection<CabinetsEntity>();
da.FetchEntityCollection(toDel, null);
foreach (CabinetsEntity cab in toDel)
{
da.FetchEntityCollection(cab.CabinetsDoors, cab.GetRelationInfoCabinetsDoors());
da.DeleteEntity(cab);
}
da.DeleteEntityCollection(toDel);
}