N-Level undo CancelEdit reverses collection order

N-Level undo CancelEdit reverses collection order

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


j0552 posted on Friday, November 16, 2012

Hi

CSLA v4.3.13

This looks like a bug to me. If I call CancelEdit on an object with a child collection the collection is restored in reverse order from the original.

Can you suggest a fix or workaround?

Thanks
Andrew

RockfordLhotka replied on Friday, November 16, 2012

It is a known behavior that deleted items restored to a collection by CancelEdit are added to the end of the collection. There's no realistic way to maintain relative positions of deleted items in the collection through a potential process of add/remove/edit changes.

As a result, the order of items in a collection is always assumed to be indeterminate. If you need a determinate order for items in the collection, you should consider using a LINQ query with ToSyncList to create a determinate view over the collection.

j0552 replied on Friday, November 16, 2012

OK

I hadn't thought about how the CancelEdit works so wrongly assumed the objects would revert to the extact original state. I'm using windows forms in this project so I've added a SortedBindingList to bind to the BindingSource. Now it works as I expected.

Thank you
Andrew

Copyright (c) Marimer LLC