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?
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?
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
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?
In this instance i need to query both published and unpublished content on the site but thanks for the advice.
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?
is working on a reply...