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");
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!
Hi Moqzilla,
Where are you doing it? In Razor? Can you try to use
Thanks, Alex
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);
is working on a reply...