This solution is obsolete. The best way to validate data in an XAF application is to use the Validation Module. Refer to the RuleIsReferencedAttribute article for a recommended solution.
This example demonstrates how to implement your classes, to save the referential integrity of your tables when removing master objects being referenced by other objects. This solution is appropriate when you have the Deferred Deletion feature of XPO turned off. Without the code in this example, you will get an SQLException. This solution will allow you to provide your users with more meaningful exceptions, when such a situation takes place.
The Master object in this example has an aggregated One-To-Many relationship to Child objects. If a Master object has some aggregated children, it can be immediately deleted with all associated Child objects. However, if there is a Neighbour object, having a reference (without association) to this Master object, the code will raise an exception, notifying about existing referencing objects.