How to sort IPrefetchPathElement2 objects

Posts   
 
    
rracer99
User
Posts: 58
Joined: 11-Mar-2007
# Posted on: 12-Apr-2007 12:19:37   

How would I sort (adapter) ppeClientPlans for example (tried several variations wthout success):



IPrefetchPath2 prefetchPath = new PrefetchPath2((int)EntityType.ClientContactsEntity);

IPrefetchPathElement2 ppeClients = ClientContactsEntity.PrefetchPathClients;
ppeClients.SubPath.Add(ClientsEntity.PrefetchPathCountryCodes);
ppeClients.SubPath.Add(ClientsEntity.PrefetchPathClientStatusTypes);

//How do I sort ppeClientPlans here against a single field? 
IPrefetchPathElement2 ppeClientPlans = ClientsEntity.PrefetchPathClientPlans;
ppeClientPlans.SubPath.Add(ClientPlansEntity.PrefetchPathClientPlanConfig).SubPath.Add(
ClientPlanConfigEntity.PrefetchPathPlanConfigParamNames);
ppeClientPlans.SubPath.Add(ClientPlansEntity.PrefetchPathClientPlanAddons).SubPath.Add(
                ClientPlanAddonsEntity.PrefetchPathPlanAddonNames);



Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 12-Apr-2007 16:07:45   

When you get to add the ppeClientPlans to a PrefetchPath2 object you should supply a sort expression. There is an overload of the prefetchPath2.Add() method that accepts a SortExpression.

rracer99
User
Posts: 58
Joined: 11-Mar-2007
# Posted on: 12-Apr-2007 22:36:27   

Walaa wrote:

When you get to add the ppeClientPlans to a PrefetchPath2 object you should supply a sort expression. There is an overload of the prefetchPath2.Add() method that accepts a SortExpression.

Yes, but my problem is I have to add the IPrefetchPathElement2 to the subpath of another, then I add the root IPefetchPathElement2 to the PrefetchPath2 object. Now if I include a sort expression I will get an error becuse the table.field I am sorting is several paths deep from the established root of the PrefectPath2 object.

For example (heirachy is clients -> clientPlans -> servers):


ppeClientPlans.SubPath.Add(ppeServers);
ppeClients.SubPath.Add(ppeClientPlans);
prefetchPath.Add(ppeClients); //here I cannot add a SortExpression for ClientPlansFields.fieldName

Thank you!

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 13-Apr-2007 11:37:45   

Yes, but my problem is I have to add the IPrefetchPathElement2 to the subpath of another

To which ever Add() method you use to supply the IPrefetchPathElement2 supply the its SortExpression too. Whether its a subPath or the main prefetchPath.

So in your case supply the sortExpression to that Add() method of the subPath you use to supply its corresponding IPrefetchPathElement2 .