Fetching and sorting related collection

Posts   
 
    
MacDennis avatar
MacDennis
User
Posts: 50
Joined: 03-May-2005
# Posted on: 06-Dec-2005 09:51:48   

How can I do the following?

Fetch one customer and the related order collection in one go where the order collection is sorted on a date field.

I'm using adapter so I need a prefetch but I can't specify a sort expression in the adapter.FetchEntity call ?

Is there a way or do I need to make 2 calls to the database? One for the customer and one for the order collection?

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 06-Dec-2005 14:32:37   

Have you tried to pass the sort expression to the prefetchpath ?!

The following is a valid overload of the PrefetchPath.Add():

PrefetchPath.Add Method (IPrefetchPathElement, Int32, IPredicateExpression, IRelationCollection, ISortExpression)
MacDennis avatar
MacDennis
User
Posts: 50
Joined: 03-May-2005
# Posted on: 06-Dec-2005 15:21:10   

Thanks! Haven't tried that yet, should work. Haven't used that overload before.

Suggestion for the manual, add a small note in the topic 'Sorting' about sorting related collections, it should point to this prefetch path sorting functionality which is indeed mentioned in the manual but I was looking in the wrong place. disappointed

Even beter, a few examples in the sorter topic about how to use a sort expression. When using it to fetch a collection .. When using it to fetch a related collection .. etc ..

I simply can't remember all the functionality / overloads this tool provides, the manual is the first place I look for answers.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 06-Dec-2005 16:21:47   

Thanks for the suggestion. Also keep an eye on the 8MB large reference manual, which contains all the overloads. simple_smile

Frans Bouma | Lead developer LLBLGen Pro