Copied to clipboard

Flag this post as spam?

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


  • Luuk Krijnen 12 posts 66 karma points
    Aug 07, 2012 @ 09:50
    Luuk Krijnen
    0

    sorting multiple datetime fields when 1 could be empty (null)

    Hi you all,

    I'm a beginning Umbraco developer and have the following question.

    I've created a news-section in my website. Nothing new and working fine. Except now I wanna sort the news items by date. One problem is that the sorting dates are spread over multiple columns. I've create a news date which isn't mandatory. When the newsdate column is empty the created date is used.

    how do I sort my newsItems using both of these column

    Example

    newsitem1: newsdate = 3 aug 2012, createDate = 7 aug 2012

    newsitem2: newsdate = emtpy, create date = 7 aug 2012

    newsitem3: newsdate = 25 jul 2012, createDate 7 aug

    Result (sorting order):

    newsitem2, newsitem1, newsitem3

     

     

  • Luuk Krijnen 12 posts 66 karma points
    Aug 07, 2012 @ 12:05
    Luuk Krijnen
    0
    something like:
     
    var nodes = @model.......OrderDesc(t=>t.newsdate.HasValue ? t.newsdate : t.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