Copied to clipboard

Flag this post as spam?

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


  • Mikkel Johansen 116 posts 292 karma points
    Jan 23, 2012 @ 13:14
    Mikkel Johansen
    0

    OrderBy: Name vs. pageName

    I am using Umbraco 4.7.1

    I want ot order nodes by the node-name.

    Thought that "Name" was the way to go - But this does NOT work:

    dynamic nodes = Model.Descendants();
    foreach (dynamic node in nodes.OrderBy("Name")
    ...

    Using "pageName" works:

    dynamic nodes = Model.Descendants();
    foreach (dynamic node in nodes.OrderBy("pageName")
    ...

    Is it correct that it is not possible to order by "Name"?

    /Mikkel

  • Michael Latouche 504 posts 819 karma points MVP 3x c-trib
    Jan 23, 2012 @ 13:32
    Michael Latouche
    0

    Hi Mikkel,

    Not until you create yourself a property on your document type with the alias called "Name"...

    Cheers,

    Michael.

  • Mikkel Johansen 116 posts 292 karma points
    Jan 23, 2012 @ 13:38
    Mikkel Johansen
    0

    But I can get the name of the node by

    @node.Name

    That's why it is a little confusing when to us "Name" or "pageName"

    If I did create a property "Name" would it not conflict. And in the build-in razor-template-snippets (eg. List subpages by limit and datetime) @item.Name is used.

     

  • Michael Latouche 504 posts 819 karma points MVP 3x c-trib
    Jan 23, 2012 @ 13:42
    Michael Latouche
    0

    Mmh,

    It is indeed a bit odd.I guess they use the dynamic "Name" property as a shortcut to the "pageName" alias, but this raises then indeed the question of what happens if you add a "Name" property yourself...

    I hope one of the razor guru's will be able to give you an answer :-)

    Cheers,

    Michaƫl.

  • Sebastiaan Janssen 5045 posts 15476 karma points MVP admin hq
    Jan 23, 2012 @ 13:53
    Sebastiaan Janssen
    0

    The Name is an actual existing property on DynamicNode and is not available as a Dynamic property, like pageName. The pageName is a shortcut to Name though.

    I think the problem here is that your can only query on dynamic properties and that Gareth might've forgotten to add Name as an additional filter.

  • Sebastiaan Janssen 5045 posts 15476 karma points MVP admin hq
    Jan 23, 2012 @ 13:55
    Sebastiaan Janssen
    0

    Actually, OrderBy("Name") works fine for me in 4.7.1.1 so this might be fixed already.

  • Mikkel Johansen 116 posts 292 karma points
    Jan 23, 2012 @ 13:56
    Mikkel Johansen
    0

    It looks like it is only "Name" the I cannont "order by". It works fine with "id", "updatedDate" and added properties on doctype.

    Looks like a bug-issue. 

  • Mikkel Johansen 116 posts 292 karma points
    Jan 23, 2012 @ 13:57
    Mikkel Johansen
    0

    I have not upgraded from 4.7.1 to 4.7.1.1

    But have looked in the changelog, but could not see any in the log.

    The plan is to do the upgrade :-)

    Thanks for helping :-) 

  • Jimmy Dan Mortensen 77 posts 197 karma points
    Jan 23, 2012 @ 15:02
    Jimmy Dan Mortensen
    0

    I had the exact same problem. See the solution here:

    http://our.umbraco.org/forum/developers/razor/27527-Order-by-not-working-i-codebehind

    Best regards
    Jimmy

Please Sign in or register to post replies

Write your reply to:

Draft