Possible bug. Adding and then deleting a child at editLevel 0 remains in deletedListPossible bug. Adding and then deleting a child at editLevel 0 remains in deletedList
Old forum URL: forums.lhotka.net/forums/t/5081.aspx
tetranz posted on Thursday, July 10, 2008
Hi Rocky and all
I think I've found a small bug in 3.0.4.0. I'm building a web app with an EditableRootList (i.e, Save() saves all children) . There's no n-level undo so BeginEdit() is never called.
If I do something like this:
ERL.AddNew()
ERL.Remove(the newly added object)
ERL[Some other Index].SomeProperty = newValue;
ERL.Save()
It tries to delete the new but then deleted child from the db. It works properly if I call BeginEdit() and AcceptEdit(). I had a quick look at the Csla code and there seems to be a test where if the deleted object is below the current editLevel then it is removed from deletedList. In my case editLevel never gets above zero so it remains in deletedList.
Cheers
Ross
RockfordLhotka replied on Thursday, July 10, 2008
So in line 3 you are re-adding the object you deleted in line 2?
That would certainly be a problem, and isn't supported. In line 2 the child object not only is moved to the deletedList, but is marked as deleted. The only way to "undelete" a child is to use n-level undo.
tetranz replied on Friday, July 11, 2008
RockfordLhotka: So in line 3 you are re-adding the object you deleted in line 2?
That would certainly be a problem, and isn't supported. In line 2 the child object not only is moved to the deletedList, but is marked as deleted. The only way to "undelete" a child is to use n-level undo.
No. In line 3 I'm editing a different child object that already existed (i.e, IsNew = false). Lines 1 and 2 simply creates a new child object and then deletes it. If I just do lines 1 and 2 then Save doesn't do anything (as expected) but that's really only because the list is not dirty. If I make the list dirty by doing something like line 3 then Save tries to unnecessarily delete the object I added and deleted but has never existed in the db.
Copyright (c) Marimer LLC