Umbraco 8 OrderBy a collection by a Custom Field Such as a Date

This is a snippet for Umbraco 8  to Order a collection by a Custom Field Such as a Date.

@{
    var selection = Umbraco.Content(Model.Id)
    .ChildrenOfType("publication")
    .Where(x => x.IsVisible())
    .OrderBy( x => x.Value("publicationDate"));
}

@foreach (var item in selection.Take(1))
{
     <h2><a href="@item.Url" title="@item.Name">@item.Name</a></h2>
}

Comments

  1. Umbraco 8 OrderBy a collection by a Custom Field Such as a Date

    Very informative post..!!

    Well, we are here to share Mobile App Development Company

    Cross Platform Mobile App Development

    Waiting for your future posts...

    ReplyDelete

Post a Comment

Popular posts from this blog

Create a .NET Contact Form that Gets the Last Url Visited in C# Can also be Used in Umbraco

Umbraco - Reset the Admin Password via SQL Server

Umbraco Macro for IFrame when Embedding Video, Vimeo Universal Player, or other types of IFrame on to a Page XSLT version and Razor Version