Copied to clipboard

Flag this post as spam?

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


  • webangelo 107 posts 190 karma points
    Jul 29, 2011 @ 16:07
    webangelo
    0

    Date Error in Razor OrderBy?

    Umbraco 4.7

    Attempting to do a double sort in Razor involving two date fields.  It seems I can sort by either of them independently, however whenever I have a date field with another field in the sort string, razor throws an error.  I can sort by two non-date fields, but if either field is a date it throws the following error:

    Error loading Razor Script
    Unable to cast object of type 'System.Func`2[umbraco.MacroEngines.DynamicNode,System.DateTime]' to type 'System.Func`2[umbraco.MacroEngines.DynamicNode,System.Object]'.

    Here are the scenarios:

    .OrderBy("createDate desc") -> Single Date ordering = success
    .OrderBy("name, location desc") -> Two non-date field order = success
    .OrderBy("createDate, location desc") -> Two date or one date and one non-date = failure
    .OrderBy("location. createDate desc") -> Two date or one date and one non-date = failure

    Before I submit this I wanted to confirm this was actually a bug and not just something I'm not understanding.

    Thanks.

    --Chris

     

  • Sebastiaan Janssen 5061 posts 15544 karma points MVP admin hq
    Jul 29, 2011 @ 16:10
    Sebastiaan Janssen
    1

    This is a known bug in 4.7 and is fixed in 4.7.1. You can download the latest nightly build and only use the umbraco.macroengines.dll, that should work fine, it's been very stable.

  • webangelo 107 posts 190 karma points
    Jul 29, 2011 @ 16:19
    webangelo
    0

    Good to know its been fixed.  I'll probably do a work-round for now and wait until 4.7.1 has been released to keep the code bases managable on my end.

    Thanks Sebastiaan. 

    --Chris

  • Carlos 338 posts 472 karma points
    Jan 09, 2013 @ 00:53
    Carlos
    0

    I know this is a really old post, but how do you sort ascending not desc?

  • Brian 3 posts 23 karma points
    Aug 07, 2013 @ 16:12
    Brian
    0

    Could it be, that the bug is 4.11.8 again or am I doing anything wrong?

  • Simon steed 378 posts 700 karma points
    Aug 07, 2013 @ 20:38
    Simon steed
    0

    Ditto on 4.11.8, similar issue here

  • 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