Sorting added entity in collection

Posts   
 
    
tprohas
User
Posts: 257
Joined: 23-Mar-2004
# Posted on: 08-Nov-2006 19:51:48   

.Net Version: 1.1 ORMSupportClasses.NET11: 2.0.0.0 Template: Adapter C#

Hello All,

I'm adding and removing entities from a collection and would like to know if the EntityCollection.Add method will sort the added entity into the correct position when added? If not, do I then have to use client side sorting to re-sort the collection after removing and then re-adding a entity?

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 09-Nov-2006 02:38:26   

You can achieve this behavior using the entityviews. You can set a sorter for the entityview and set the DataChangeAction to PostCollectionChangeAction.ReapplySorter. This will then reapply the sorter to the entityview when you add and entity for the collection.

This method is covered more in the manual under Generated code - Using the EntityView2 class, Adapter.