Sorting by field mapped as relation

Posts   
 
    
Don
User
Posts: 2
Joined: 07-Nov-2005
# Posted on: 07-Nov-2005 20:04:25   

I have something like:

Customer custid

Order custid orderid

Orderitem orderid

OrderDesc orderid orderDesc

I am attempting a fetchEntity to return a Customer Entity with all OrderItems for the customer sorted by the order description. In the designer I have orderdesc as a field mapped on related fields as part of the OrderItem entity.

I have tried the following with no success

Dim Cust As New CustomerEntity(custId)

Dim prefetchPath As New PrefetchPath2(CInt(EntityType.CutomerEntity)) Dim referencePath As IPrefetchPathElement2 = CustomerEntity.PrefetchPathOrder

Dim sortClause As ISortClause = SortClauseFactory.Create(OrderDescFieldIndex.OrderDesc, SortOperator.Ascending)

referencePath.SubPath.Add(ReferenceEntity.PrefetchPathOrderItem)

prefetchPath.Add(referencePath) adapter.FetchEntity(Cust, prefetchPath)

Do I have to create a Typed List? Any suggestions?

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 08-Nov-2005 03:03:31   

Try passing the sort expression in with the prefetch definition for the orderitem along with a RelationCollection to define the relation between orderitem and order description.

Don
User
Posts: 2
Joined: 07-Nov-2005
# Posted on: 08-Nov-2005 20:57:25   

Thanks! That seems to have done the trick.