HierarchicalObject doesn't delete children..

HierarchicalObject doesn't delete children..

Old forum URL: forums.lhotka.net/forums/t/9630.aspx


idroesse posted on Wednesday, October 13, 2010

Hi guys, I have a strange behaviour.  I have a child object (let me call it "MyObject") derived from BusinessObject and, within this object, i have a BusinessListBase object of "MyObject" (a tipical Tree structure). 

When i delete an element from the BusinessListBase within MyObject, Child_DeleteSelf is only executed in this object and not into the children, even if I call "FieldManager.UpdateChildren(this)".

This is an example:

MyObject a = new MyObject();

MyObject a1 = new MyObject();

MyObject a11 = new MyObject();

MyObject a111 = new MyObject();

a11.Children.Add(a111)

a1.Children.Add(a11)

a.Children.Add(a1);


If I delete "a1" from "a" Child_DeleteSelf is called only for "a1", but i need to remove even "a11" and "a111". "a", "a1", "a11" and "a111" come from the same SQL Table, so I can't use the cascade delete on SQL, I need to delete every row manually.. The only solution I found to solve this problem is overriding RemoveItem method within BusinessListBase and Clear the BusinessListBase object of the deleted object.

Is this behaviour right or is there something wrong in my code?

Best regard,

Enrico

 

tiago replied on Wednesday, October 13, 2010

This is standard and there are 3 solutions. You mentioned 2 and the 3rd replaces cascade delete: solve the problem in the stored procedure. In your case, as you can't cascade delete, there is only the solution you are using.

idroesse replied on Thursday, October 14, 2010

It was my suspicion. Thank you for your reply

Best regard

Enrico

Copyright (c) Marimer LLC