Copied to clipboard

Flag this post as spam?

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


  • Gabe Alam 6 posts 96 karma points
    23 days ago
    Gabe Alam
    0

    ContentService GetPagedDescendants no results

    Umbraco 8

    I'm trying to get all nodes of a certain type - regardless of publish state (hence why I'm using ContentService). I figured I'd get all nodes and filter from there.

    From the code as well as other forum threads it seems like I want ContentService.GetPagedDescendants() - but I'm running into an issue where it returns 0 elements. Even more curiously, the out totalRecords does return the proper number.

    Here's my content structure:

    And the code:

    As you can see, descendants has 0 elements but returnCount is 3 (as is expected).

  • Bryna 58 posts 219 karma points
    23 days ago
    Bryna
    0

    I am also getting this, even when I pass in -1 for the rootNode.Id. I am able to do below:

    IEnumerable<IContent> z =  contentService.GetPagedDescendants(-1, 1, 1000, out totalStale).Where(x => x.Published).AsEnumerable<IContent>()
    

    But 0 results are returned. How 0dd. Does it work for you when you move the code into a Razor View and Use IPublishedContent instead? Depending on what you are trying to accomplish, this might be a viable alternative.

  • Gabe Alam 6 posts 96 karma points
    23 days ago
    Gabe Alam
    0

    I haven't tried anything with IPublishedContent as I need all IContent, not just published elements. This is being used in an on save handler so there's no view for it.

Please Sign in or register to post replies

Write your reply to:

Draft