Copied to clipboard

Flag this post as spam?

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


  • Murray Roke 503 posts 966 karma points c-trib
    Sep 08, 2011 @ 07:27
    Murray Roke
    0

    When working in razor do you use: DynamicNode or INode?

    Hi Everyone.

    I'm wondering how many people are using DynamicNode  in thier razor scripts vs how many are using strongly typed nodes?

    I started out doing everything with DynamicNode which does some things better, but end up converting nodes to INodes for all the convenince methods I have written (and uQuery ones)

    What are your pain pionts with either aproach? 

    Cheers.

    Murray.

  • Sebastiaan Janssen 5058 posts 15520 karma points MVP admin hq
    Sep 12, 2011 @ 17:41
    Sebastiaan Janssen
    0

    I just like using the "pure" implementation, so I use DynamicNode (or, even more vague: dynamic). That way I know I have all of the operations I want (like Descendants(), Children, Parent, Next(), Previous() etc.) without running into compile issues. 

    For loads of examples, have a look at my Razor Examples package, it uses dynamic everywhere and hardly ever does any static typing. I found that once you get used to this way of working and have plenty of examples on file, it gets really easy to do everything without having to do loads of casting.

    I do like uQuery and UQL, but I haven't really found a "killer" feature in them, I don't want to add another dll when the out-of-the-box experience is fine for me (personally).

    That said, I know loads of people love the safety net of having code completion with static types and that's great, go for it! Just know there's alternative ways. :-)

  • andrew shearer 510 posts 659 karma points
    Sep 12, 2011 @ 23:52
    andrew shearer
    0

    this is one of the biggest problems with DynamicNode imo:

    http://umbraco.codeplex.com/workitem/30459

     

  • Sebastiaan Janssen 5058 posts 15520 karma points MVP admin hq
    Sep 13, 2011 @ 00:18
    Sebastiaan Janssen
    0

    Hmm, well, I would say that's a bit annoying but there might be a good reason for this behaviour. I never really get invalid nodeId's in there though, so it's not a problem for me.

    A workaround could be to test if myNode.Name == string.Empty. That should never happen in real life, all nodes should have a name.

Please Sign in or register to post replies

Write your reply to:

Draft