Gravatar for

Question by jthirus, Jul 5, 2016 3:37 PM

Using Linq's OrderByDescending on a Date


I'm trying to sort based on a date field in our Sitecore items and am having issues. The items are showing up with a random set in a random order. The code is as follows:

        using (var context = index.CreateSearchContext())
            var queryable = context.GetQueryable<BlogPostModel>();
            var query = queryable
                .Where(x => x.Paths.Contains(pathId))
                .Where(x => x.WorkflowStateID == lookupWorkstate)
                .OrderByDescending(x => x.PublishDate)
                .Skip(id * size)

            foreach (var item in query)


The field is configured in our search index:

< fieldType fieldName="Publish Date" isSortable="true" settingType="Coveo.Framework.Configuration.FieldConfiguration, Coveo.Framework" />

It shows up in the field set for my index as a Date/time.

Is this something we are doing wrong or does Coveo not support OrderByDescending?


Sitecore version: 7.5 (rev. 141003) Coveo version: 7.0 x64 Build 8225.0

0 Reply
Ask a question