Copied to clipboard

Flag this post as spam?

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


  • martin macdonald 6 posts 76 karma points
    Aug 18, 2016 @ 09:52
    martin macdonald
    0

    Content Service GetDescendants not returning expected results

    Hey Guys,

    Im trying to get a list of all published and unpublished content using the content service IEnumerable<IContent> contentdescendants = ervices.ContentService.GetDescendants(id);

    however it only returns 3 results.

    But when i do Services.ContentService.GetDescendants(1054).Count() it returns 77 which i would expect which I can then filter.

    Ive also tested with the method IEnumerable<IContent> content = Services.ContentService.GetById(id).Children();

    which correctly returns all the direct children of the node id i pass in.

    Any ideas what would be causing the GetDescendants(int id) method to fail and not return all the descendants?

    Thanks in advance

  • Sebastiaan Janssen 5045 posts 15478 karma points MVP admin hq
    Aug 18, 2016 @ 10:06
    Sebastiaan Janssen
    0

    First off: please, please, please only use the ContentService for querying if you're absolutely sure that you need the ContentService. If you're looking for published content then make sure to use the UmbracoHelper to do querying: https://our.umbraco.org/documentation/reference/querying/UmbracoHelper/

    Why? Because ContentService goes straight to the database and circumvents all caching. This will perform horribly especially as your site starts growing.

    That said, this seems to be working for me, did I do something different?

    enter image description here

    enter image description here

  • martin macdonald 6 posts 76 karma points
    Aug 18, 2016 @ 10:24
    martin macdonald
    0

    In this instance i need to query both published and unpublished content on the site but thanks for the advice.

    If i run the child method i get this result

    But when i try to do the descendant i get this

  • martin macdonald 6 posts 76 karma points
    Aug 18, 2016 @ 13:40
    martin macdonald
    0

    So i done some more digging and found the issue.

    It turns out when i done a move umbraco nodes from folder 1054 to a new root folder of 1270 this path/ parent node wasnt updated correctly.

    Are you aware of any bugs within the umbraco move method?enter image description here

Please Sign in or register to post replies

Write your reply to:

Draft