Sorting issue ...

Posts   
 
    
HcD avatar
HcD
User
Posts: 214
Joined: 12-May-2005
# Posted on: 31-Mar-2006 22:16:07   

Hi

I'm having trouble finding how i can solve the following issue. Suppose I have a MainEntity which has a collection a subobjects (1:n relation) accessible through MainEntity.SubObject It is then easy to bind the subobjects to a datagrid using: dataGrid1.DataSource = MainEntity.Subobject.; The subobject collection can also be sorted first before binding it using :


MainEntity.SubObject.SupportsSorting = true;
Mainentity.SubObject.Sort(((int)SubObjectFieldIndex.Fieldname,ListSortDirection.Descending,Comparer.Default);

Now my problem is that i want to sort the SubObject collection using a criteria field that is not part of the SubObject record, but some 1:1 related entity (of SubObject) Let's suppose the SubObjectEntity is 1:1 related (or m:1, doesn't matter) to AnotherObjectEntity, and AnotherObjectEntity has a SortOrderField according to which I want to sort. So something like SubObject.AnotherObject.SortOrderField. How could i achieve this ?

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 01-Apr-2006 03:57:12   

You could set it up as a field on a related field in the designer and sort on that as long as you prefetch the related entities.