Get all children of a node including unpublished

I’m trying to get all children inside a folder at root level so I’m using

_umbracoHelper.Value.ContentAtRoot()
.FirstOrDefault(c => c.ContentType.Alias.Equals("Folder"))
.Children();

But it doesn’t include the unpublished content.

Is there a way to get all the children of that folder including the unpublished content?

Perhaps you can give us more context on what you want to do. The UmbracoHelper only works on published content, so that is true. Beware that getting non-published content usually is very slow and involves database queries, so don’t get unpublished content on anything that is meant to be displayed on the frontend.

There are ways to get data for instance from the InternalIndex, and there are some services that work on a cache, so it depends on what you need and want to do.

I was trying to synchronise a load of documents with some internal data but there were over 1000 and I found the getpagechildren of the content service to be very slow as you said so thought I may be able to use the umbraco helper instead as that seemed to be a lot faster

Hi @Pete0000

If you need to check both published and unpublished content, I would start by using a query as you have using the UmbracoHelper to find a match, and if not found, then fallback to the unpublished content via the IContentService. That way, if you have more published content then unpublished, then hopefully the impact on performance is more manageable.

You can use filters in the IContentService to try and improve the lookup performance, but it is still a database hit.

Obviously, if you need to update content, you will still need to do this via the IContentService and the published content cache is read-only.

The other option is to use the Examine InternalIndex, but I find indexes not to be the most reliable as they tend to get corrupted easily or out of sync.

Justin

The other option is to use the Examine InternalIndex, but I find indexes not to be the most reliable as they tend to get corrupted easily or out of sync.

Agreed, but that really depends on what you want to do. If you want to synchronise some data by checking a node and actually updating it, don’t bother with published content AT ALL. You want the latest data and published data can be outdated compared to the unpublished data.

And for a one-time things, performance is way less relevent than a recurring thing.

I really think that for the best answer @Pete0000 needs to give us more information about what he wants to do :slight_smile: