This is a migrated thread and some comments may be shown as answers.

Keeping a list sorted

1 Answer 72 Views
Development (API, general questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
cayates
Top achievements
Rank 1
cayates asked on 02 Feb 2009, 03:25 PM
Hello,

I have a list of objects that are mapped to a table using Open Access.  Each time a new object is added to the list it needs to be sorted using a custom comparison method.  Normally I would just create an IComparer class and use List<>.Sort(IComparer<>), however, when I try to do this with the Open Access enhanced list I get this error:

Unable to cast object of type 'Telerik.OpenAccess.TrackedList`1[CJIS.Model.Charge]' to type 'System.Collections.Generic.List`1[CJIS.Model.Charge]'.

The TrackedList object does not have a Sort method.  So how would I accomplish this?

Thank you.

1 Answer, 1 is accepted

Sort by
0
Jan Blessenohl
Telerik team
answered on 04 Feb 2009, 12:21 PM
Hello cayates,
The speciality about sorting is it will remove/add persistent objects from/to the collection, those operations are possibly not intended and we do not implement the sort interface.

What you can do is to implement your derivation from TrackedList<T> and add the sort capability. You can use such a SortableTrackedList<T>:TarckeList<T> directly in your persistent model.

Sincerely yours,
Jan Blessenohl
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Development (API, general questions)
Asked by
cayates
Top achievements
Rank 1
Answers by
Jan Blessenohl
Telerik team
Share this question
or