Hello!
Ok.. it seems my day for posting today.
I am hoping this is something I am just doing wrong but it appears that my EntityCollection is sorting in ASC rather than DESC as I have asked it to..
I am using this code to Call back an Entity Collection:
public static EntityCollection GetLatestTrackingInformationForOrderDetail(Guid orderDetailId)
{
EntityCollection orderDetails = new EntityCollection(new JobTicketTrackingEntityFactory());
IPrefetchPath2 prefetch = new PrefetchPath2((int)EntityType.JobTicketTrackingEntity);
prefetch.Add(JobTicketTrackingEntity.PrefetchPathDocumentBackCoverTracking);
prefetch.Add(JobTicketTrackingEntity.PrefetchPathDocumentBodyTracking);
prefetch.Add(JobTicketTrackingEntity.PrefetchPathDocumentFrontCoverTracking);
IRelationPredicateBucket bucket = new RelationPredicateBucket();
bucket.PredicateExpression.Add(JobTicketTrackingFields.OrderDetailId == orderDetailId);
SortExpression sorter = new SortExpression(JobTicketTrackingFields.DateChanged | SortOperator.Descending);
using (DataAccessAdapter a = new DataAccessAdapter())
{
a.FetchEntityCollection(orderDetails, bucket, 0, sorter, prefetch);
}
return orderDetails;
}
Then calling this via a webservice and using it in a windows form.
In my windows for I do this:
JobTicketTrackingEntity jobTicket = (JobTicketTrackingEntity)orderDetail[0];
to get the entity with the latest date but I am getting the one with the oldest date!
I have used SQL Profiler and it's posting 4 queries and the query for the JobTicketTracking definitly has "Desc" in it, but when I loop the entity collection it's ascending by date not descending!
What on earth is going on?
Thanks
Bex
I am using Adapter, v2.6