linq list sorting on a custom field value

Topics: Customizing Orchard, Troubleshooting
Apr 1, 2014 at 4:45 PM
Hi all-

Trying to work out how you would sort a set of custom contenttype objects based on one of their fields. I've attempted this but it fails because the dynamic classes don't implement IComparable.

Here's my failed attempt:
List<ContentItem> foundItems;
if (string.IsNullOrEmpty(q))
        foundItems = _contentManager.Query().ForType(new string[] { "BlogPost" }).List().OrderByDescending(c => c.Parts.First(p => p.PartDefinition.Name == "BlogPost").Fields.First(f => f.Name == "ArticleDate")).ToList();