Jul 17, 2012 at 6:06 PM
Edited Jul 17, 2012 at 7:50 PM
Well...the good thing is the Foreign Key Constraint works. The bad thing is, the delete method now fails with the error:
The primary key value cannot be deleted because references to this key still exist.
My guess is that it's trying to delete the ParentRecord before the ChildRecords
in my controller where ParentRecord is defined as
var ParentRecord = _orchardServices.ContentManager.Get(ParentRecordId);
Is there possibly a different way to remove the Content Item that triggers the deletion of all ChildRecords before attempting to remove the ParentRecord?
Thanks for any help
btw...my handler has an OnRemoved function that deletes the ContentPart from the Repository...this is apparently where the Foreign Key constraint was blowing up the delete. I removed this and attempted the Delete again.
It marks the VersionRecord for the Parent item as Published = false, but does NOT mark the Published property of the Child item's VersionRecord as false or do anything with the Child item whatsoever.
And of course my PartRecords are still in my table since I commented out the OnRemoved part in the Handler.
The Foreign Key Constraint only seems to come into play when attempting to delete the ContentParts from my table.
Not sure if any of that info helps
I suppose if I can just simply mark any Child items as Published = false in the VersionRecord and delete the ContentParts from my table, that would work. I could then just come up with something that deletes any ContentItems that aren't Published later on
if I need to delete them.