Copied to clipboard

Flag this post as spam?

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


  • mogzilla 2 posts 22 karma points
    May 16, 2015 @ 19:34
    mogzilla
    0

    Ordering parent using the CreateDate of its children

    Hi,

    Does anyone know how to order a parent by the CreateDate of it's children? It's for a simple forum I'm trying to make and I'm wanting to order the topics by latest replies (i.e. its children)

    This is what I've got so far, which just orders by when the topic was created rather than latest replies

    var topics = CurrentPage.Children().Where("NodeTypeAlias == \"Topic\"").Where("Visible").OrderBy("CreateDate desc");

    Thanks!

  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    May 16, 2015 @ 20:29
    Alex Skrypnyk
    0

    Hi Moqzilla,

    Where are you doing it? In Razor? Can you try to use

    var orderedList = Umbraco.AssignedContentItem.Children.OrderBy(x => x.Children.First().CreateDate);
    

    Thanks, Alex

  • mogzilla 2 posts 22 karma points
    May 16, 2015 @ 22:55
    mogzilla
    0

    Hi Alex,

    Yes, in a razor partial template.

    That didn't work, got an error saying the sequence contains no elements

    var topics = Model.Content.Children.Where("Visible").OrderBy(x => x.Children.First().CreateDate);

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies