If
it is SQL Server DB, you can setup relationship to cascade deletes. Otherwise,
you will need to override DataPortal_Delete in the parent and manually perform
delete operations in desired order by calling deletes of children first, then
parent.
Sergey Barskiy
Principal Consultant
office: 678.405.0687 |
mobile: 404.388.1899
Microsoft Worldwide Partner of the Year | Custom
Development Solutions, Technical Innovation
From: LTW
[mailto:cslanet@lhotka.net]
Sent: Tuesday, April 07, 2009 12:52 PM
To: Sergey Barskiy
Subject: [CSLA .NET] Delete, Referential Constraint
I have a child object that has the
"Delete_Self(parent)" method called by way of the the parent object
implementing the "FieldManager.UpdateChildren()" method. In the
Delte_Self method I call a Stored Procedure that Deletes the object. However,
the Row that is deleted is the parent of another child, which is represented as
a Primary Key/Foreign Key relationship in the database. Therefore, a
"reference constraint" error is thrown when the attempt is made to
delete the row. What I need to do is have the Child objects deleted before the
parent is. My question is, does CSLA have a way to deal with this. I do not see
anything in C# 2008 Business Objects book. My idea was to clear() the
child collection and than call the save() method on the child collection inside
the "Delete_Self" method of the parent, before I call the stored
procedure, but it seems to me CSLA would have something built in to deal with
this. Any ideas?
Copyright (c) Marimer LLC