BusinessListBase<T, C> bug?

BusinessListBase<T, C> bug?

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


jureleskovec posted on Friday, July 24, 2009

Use case:
list.BeginEdit();
list.Add(child1);
list.Remove(child1);
list.Add(child1);
list.AcceptChanges();



On the last line the 'Edit level mismatch' occurs. I traced this issue inside the Csla a bit I think this happens because the child's edit level is decreased twice:
1. because it is in the deleted list (because it was removed).
2. because it is a part of the list (object tree) itself.

This is a more general problem when having an object in the object tree referenced more than once.

We found a workaround for the issue but it is getting really annoying since the pattern causing it is widely used. There are many cases where users arbitrarily add and remove items to/from a list.


-- Jure


RockfordLhotka replied on Monday, July 27, 2009

What version of CSLA?

jureleskovec replied on Tuesday, July 28, 2009

Version 3.6.2.0


-- Jure

RockfordLhotka replied on Tuesday, July 28, 2009

It is true that the default behavior of BLB doesn't allow you to re-add the same instance that was deleted.

The reason, is that the object is in the deleted list and is used as a marker so the data will be deleted. The fact that another object has subsequently been added to the active list is fine, but that's an insert operation, because the old object will be deleted.

If you don't like that behavior, you'll need to create a subclass of BLB and override some methods to change the default behavior.

iirc, this question came up a few years ago, and I opened up some methods (made them protected) so it was possible for a subclass to remove an item from the deleted list - thus allowing you to override the insert behavior (which is ultimately what Add() calls) to remove the item from the deleted list before doing the actual insert.

Obviously that changes the semantic behavior of BLB rather a lot, but it allows you to get the behavior you are after.

Copyright (c) Marimer LLC