Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi All,
try as I might I can't get order by to work... I'm trying to order on a datetime desc but having no luck at all..
Cheers,
Tom
@inherits umbraco.MacroEngines.DynamicNodeContext @{ var displayType = PageData[0]; var events = Model.NodeById(1109).Children.OrderBy("dateTime desc"); if(events.Any()) { <section id="events"> @foreach (var currentEvent in events) { var eventDateTime = currentEvent.dateTime; <article> <header><h3>@currentEvent.title</h3></header> <time datetime="@eventDateTime.ToString("yyyy-MM-ddTHH:mm")Z">@eventDateTime.ToString()</time> @if(!string.IsNullOrEmpty(currentEvent.location.ToString())) { <section> <h4>Location</h4> @currentEvent.location </section> } @if(!string.IsNullOrEmpty(currentEvent.description.ToString())) { <section> @currentEvent.description </section> } </article> } </section> } }
In 4.7 there is a bug with OrderBy(descending) function, and it's fixed in 4.7.1 as they said.
http://umbraco.codeplex.com/workitem/30198
Here is a alternative you can use to list node in descending:
http://www.uwebzone.com/blogs/umbraco/how-to-sort-node-descending-with-razor-macro.aspx
Hi Owen,
unfortunately it is not fixed in 4.7.1
i ended up using
var events = new DynamicNode(1109).GetChildrenAsList.Items.OrderByDescending((dynamic dn) => dn.dateTime);
to get around it
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
OrderBy not working in 4.7.1
Hi All,
try as I might I can't get order by to work... I'm trying to order on a datetime desc but having no luck at all..
Cheers,
Tom
@inherits umbraco.MacroEngines.DynamicNodeContext @{ var displayType = PageData[0]; var events = Model.NodeById(1109).Children.OrderBy("dateTime desc"); if(events.Any()) { <section id="events"> @foreach (var currentEvent in events) { var eventDateTime = currentEvent.dateTime; <article> <header><h3>@currentEvent.title</h3></header> <time datetime="@eventDateTime.ToString("yyyy-MM-ddTHH:mm")Z">@eventDateTime.ToString()</time> @if(!string.IsNullOrEmpty(currentEvent.location.ToString())) { <section> <h4>Location</h4> @currentEvent.location </section> } @if(!string.IsNullOrEmpty(currentEvent.description.ToString())) { <section> @currentEvent.description </section> } </article> } </section> } }
In 4.7 there is a bug with OrderBy(descending) function, and it's fixed in 4.7.1 as they said.
http://umbraco.codeplex.com/workitem/30198
Here is a alternative you can use to list node in descending:
http://www.uwebzone.com/blogs/umbraco/how-to-sort-node-descending-with-razor-macro.aspx
Hi Owen,
unfortunately it is not fixed in 4.7.1
i ended up using
to get around it
is working on a reply...