Copied to clipboard

Flag this post as spam?

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


  • Samah 2 posts 82 karma points notactivated
    Mar 18, 2018 @ 07:29
    Samah
    0

    Get Content From Umbraco Api (UmbracoHelper)

    When i get the Content from Umbraco Apis, i use this method

    var Nodes= umbracoHelper.TypedContentAtRoot().DescendantsOrSelf("docTypeAlias"); 
    

    is there a cleaner way?or more optimized way? since it queries the complete Umbraco tree

  • Kevin Jump 1867 posts 11859 karma points MVP 4x c-trib
    Mar 18, 2018 @ 11:03
    Kevin Jump
    101

    Hi

    you are right there is some info about avoiding DescendantsOrSelf in the Common Pitfalls section of the documention.

    On of the quickest* alternatives is to use the XPath functions to query the Cache and get the documents that way

    var nodes = umbracoHelper.TypedXpath("//docTypeAlias") ;
    

    This will query the Umbraco cache and return all the doctypes way faster (as it doesn't load the published content items to do the query)

    *Examine is also a quick way, but i think people doing performance tests have found the xpath as quick if not quicker in some situations.

  • 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