IPublishedContent.Children’ is obsolete

The below code works in Umbraco 17 although I get the warning

`IPublishedContent.Children’ is obsolete: 'Please use either the IPublishedContent.Children() extension method in the Umbraco.Extensions namespace, or IDocumentNavigationQueryService if you only need keys. Scheduled for removal in Umbraco 18.`

IPublishedContentQuery _contentQuery;

var count = _contentQuery

.ContentAtRoot()

.SelectMany(m=> m.Children).ToList();`

The warning occurs on `m.Children|. I tried adding Umbraco.Extensionswhich then needs INavigationQueryService (I think) but that didn’t work as intended as it throw errors regarding registering Navigation Dependency which for this should be handled by Umbraco. Changed to Navigation Service and receive below error depending on how I fill in the parameters

`System.InvalidOperationException: Unable to resolve service for type ‘Umbraco.Cms.Core.Services.Navigation.INavigationQueryService’ while attempting to activate ‘MyProject.Controllers.MyController’.`

I cant register this dependency as its part of Umbraco.

Even though the code works as required I just cant get rid of the warning

``IPublishedContent.Children’ is obsolete: 'Please use either the IPublishedContent.Children() extension method in the Umbraco.Extensions namespace, or IDocumentNavigationQueryService if you only need keys. Scheduled for removal in Umbraco 18.``

Did I miss a trick?

Hey there Keith :waving_hand:

I think you should be able to make it work by using the Children() method instead (you’re using the Children property there) — it’s a bit confusing and quite easy to miss, even when seeing the errormessage.

/Chriztian