Related Entities

Posts   
 
    
bjacobs
User
Posts: 73
Joined: 20-Aug-2008
# Posted on: 19-Dec-2008 16:38:26   

Is there a way to find out if an entity that I am trying to delete, has any related entities, without having to handle the exception that is thrown when it does?

For example let's say I have a the following:

A PatientDiagnosisEntity A PatientHospitalizationEntity

The PatientHospitalizationEntity has a list of PatientDiagnosisEntity(s).

Now if I try to delete a PatientDiagnosisEntity which has been assigned to a PatientHospitalizationEntity, I would like to know this before I attempt a delete instead of having to wait for an exception to be thrown.

Note: I have not preloaded any of the related entities to do simple count checks.

Thanks,

Billy Jacobs

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 19-Dec-2008 19:55:10   

Is there a way to find out if an entity that I am trying to delete, has any related entities, without having to handle the exception that is thrown when it does?

I.M.O. the two ways of doing this are:

  1. Fetch the related collections before delete action and check the counts.
  2. Perform a DeleteEntitiesDirectly passing a filterBucket that contains the subqueries that test the existence of related entities (see FieldCompareSetPredicate).
David Elizondo | LLBLGen Support Team