Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Referential Integrity
Message
From
14/04/2009 19:00:10
 
 
To
All
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Title:
Referential Integrity
Environment versions
Environment:
C# 3.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01394872
Message ID:
01394872
Views:
119
The Mere Mortals .NET Framework provides a business object property called AutoDeleteOnParentDeleted that can be used to automatically cascade the deletion of a parent record to all related child records. But I am surprised that the framework does not seem to provide an automatic way to restrict deletion of a parent record when related child records exist. By default, AutoDeleteOnParentDeleted defaults to false which allows deletion of a parent record only and can leave orphaned child records.

I want to restrict the deletion of a parent record if any related child records exist and I want to notify the user why the deletion failed. I can think of a couple of possible ways to accomplish this but I wonder what other developers have done. I could probably set some constraints on the backend SQL tables to solve this problem, or maybe I could put code in the mmBusinessForm.HookPreDelete(DataRowView, drView) method to iterate through the RefBizObj collection of child business objects to see if any of them have records. If child records are found I could return false which would prohibit the deletion of the parent record. The problem with this solution is that only the parent DataRowView to be deleted is passed into the HookPreDelete method and I am not sure how I could reference the child records etc. from there.

It seems like restricting the deletion of the parent record when related child records exist must be a common requirement, but as far as I can see, Mere Mortals does not provide an automatic way to handle this requirement.

Sam Tenney
Next
Reply
Map
View

Click here to load this message in the networking platform