Sorted Collection

Sorted Collection

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


Lazaro posted on Wednesday, October 27, 2010

Hello,

We are migrating from an old CSLA version (1.3.0) to 3.8.3 and we need some help with the BusinessListBase and sorting.

We had the following functionality:

base.ApplySort("StartDate", System.ComponentModel.ListSortDirection.Ascending);

 

It was used for some business collections that needed sorting because the implemented logic assumed that the collection is always sorted and validated rules based on that assumption (e.g. only last one could be edited, deleted).

What do you recommend as equivalent in 3.8 when the collection itself relies on it being sorted always? (in other words, it is not a functionality of the consumer to sort it)

Thanks,

RockfordLhotka replied on Wednesday, October 27, 2010

You probably need to consider maintaining a private reference to the actual child collection, and exposing a SortedBindingList as your public-facing property.

SortedBindingList is a wrapper, or view, over a collection. In your case the only view you want consumers to see is the sorted list, so expose that as your property. But you still need to maintain (and persist) the actual collection.

Copyright (c) Marimer LLC