Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ran Chen 40 posts 117 karma points
    Jul 09, 2015 @ 08:58
    Ran Chen
    0

    Umbraco 7 DynamicPublishedContentList OrderBy

    Hi ,

    I've created a method returning DynamicPublishedContentList object:

    public static DynamicPublishedContentList GetAllChildren(...)
    

    I would like to order the search results, I was trying to use the OrderBy method

    DynamicPublishedContentList retval = new DynamicPublishedContentList();
    ...retval retrieves data...
    return (DynamicPublishedContentList)retval.OrderByDescending(o => o.GetPropertyValue("PublicationDate"));
    

    but the types don't match

    Unable to cast object of type 'System.Linq.OrderedEnumerable`2[Umbraco.Web.Models.DynamicPublishedContent,System.Object]' to type 'Umbraco.Web.Models.DynamicPublishedContentList'.
    

    Any other solution for a method that should return sorted DynamicPublishedContentList object ?

  • Omar 1 post 71 karma points
    Oct 31, 2015 @ 09:55
    Omar
    0

    Try:

    ....GetAllChildren().OrderBy("MyField desc");
    
Please Sign in or register to post replies

Write your reply to:

Draft