Copied to clipboard

Flag this post as spam?

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


  • Gareth Wright 32 posts 101 karma points c-trib
    Dec 09, 2016 @ 15:19
    Gareth Wright
    0

    Recursive or not?

    Hi,

    I have some properties on my homepage that cover the entire website. E.g. Logo.

    I would like some advice on whether to use the following for performance?

     [UmbracoProperty("Logo", recursive:true)]
    

    or

    [Homepage, UmbracoProperty] 
    

    Where the homepage attribute simply returns:

     return Context.Content.AncestorOrSelf(0);
    

    I would have though the homepage attribute would be better for performance than recursively finding the property?

    Thanks

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Dec 09, 2016 @ 15:28
    Lee Kelleher
    100

    Hi Gareth,

    Personally I go with...

    [Homepage, UmbracoProperty]
    

    Although I do separate them on their own lines - and add the Order attribute. (Only because I've read that attributes aren't guaranteed to preserve their order).

    [Homepage(Order = 1)]
    [UmbracoProperty(Order = 2)]
    

    I know it doesn't look as succinct, but at least the order is guaranteed.

    Cheers,
    - Lee

  • Gareth Wright 32 posts 101 karma points c-trib
    Dec 09, 2016 @ 15:30
    Gareth Wright
    0

    Excellent, thank you.

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Dec 09, 2016 @ 15:32
    Lee Kelleher
    0

    In answer to your question about the recursive performance... I guess this depends how deep your content-tree goes. If we're talking about a few levels deep, then there's not much performance hit. If you're going several, then yeah you'll start to see it.

    With the going direct approach is probably better, as you know exactly where you want to get the property value from. You could even start to add caching on to the Ditto processors?

    Cheers,
    - Lee

Please Sign in or register to post replies

Write your reply to:

Draft