Copied to clipboard

Flag this post as spam?

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


  • Amir Khan 1289 posts 2746 karma points
    May 20, 2013 @ 15:54
    Amir Khan
    0

    Take combined with OrderBy isn't returning expected results

    Hi, I have this loop thats supposed to print the latest 3 blog posts and sort them by the postDate (datepicker) property. Whats happening is that if there are more than 3, it doesn't actually show the most recent one, if I change the Take(3) to Take(4) it shows the latest 4 items in the correct order. Any idea why this is happening?

     

    foreach (var node in nodes.Take(3).OrderBy("postDate desc"))

    -Amir

  • Ulrich Wagner Gade Ebsen 127 posts 277 karma points
    May 20, 2013 @ 15:57
    Ulrich Wagner Gade Ebsen
    101

    Hi,

    Try to change the order.. ie. "nodes.OrderBy("postDate desc").Take(3)" .. ;)

    /ulrich

  • Amir Khan 1289 posts 2746 karma points
    May 20, 2013 @ 16:00
    Amir Khan
    0

    Ulrich, you are the man! Thank you!

    -Amir

  • 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