Sorting EntityCollection On Related Entity

Posts   
 
    
Posts: 98
Joined: 09-Feb-2005
# Posted on: 13-Jan-2006 23:50:32   

Suppose I have an entity collection of order, each of which has a customer. I'm displaying this in a .net 1.1 datagrid. In the grid I may display the order date and the customer name.

I can sort on the order date, since I have a collection of orders, but is it possible to also sort by customer name? (Client side sorting)

If not, what is the workaround? Pull a datatable instead?

Thanks!

Paul.Lewis
User
Posts: 147
Joined: 22-Aug-2005
# Posted on: 14-Jan-2006 04:31:53   

Jeff,

I cut this from the LLBLGenPro.chm:

How do I enable sorting functionality of an entity collection in a bound grid?The Adapter's EntityCollection class and the SelfServicing entity collection classes implement the IBindingList.SupportsSorting property and the IBindingList sorting functionality. Setting this property to true/True before the collection is bound to a grid, will make sure that the grid will be able to sort the contents of the collection when the user clicks a column header. Some grid controls offer sorting capabilities without this property, however grids based on .NET's own grid control require this property set to true to enable sorting capabilities.

Posts: 98
Joined: 09-Feb-2005
# Posted on: 14-Jan-2006 05:32:01   

Paul.Lewis wrote:

Jeff,

I cut this from the LLBLGenPro.chm:

How do I enable sorting functionality of an entity collection in a bound grid?The Adapter's EntityCollection class and the SelfServicing entity collection classes implement the IBindingList.SupportsSorting property and the IBindingList sorting functionality. Setting this property to true/True before the collection is bound to a grid, will make sure that the grid will be able to sort the contents of the collection when the user clicks a column header. Some grid controls offer sorting capabilities without this property, however grids based on .NET's own grid control require this property set to true to enable sorting capabilities.

Hi Paul, but don't I need to sort the collection with a command like: [EntityCollectionName].Sort(FieldName....)?

The problem with this is that I can only sort based on the base item. So if I have a collection of orders, I can sort on any field in the order's collection. However, if I want to sort on an item RELATED to an order, like the customer, how would I do that?

Thanks

sparmar2000 avatar
Posts: 341
Joined: 30-Nov-2003
# Posted on: 14-Jan-2006 18:31:37   

if I want to sort on an item RELATED to an order, like the customer, how would I do that?

Jeff Can you clarify please. Would the RELATED item be 'fieldname' of the enity in the collection? To use your example, would customer be a field of Order?