Replacement for IPublishedCache.GetAtRoot()

In v15/v16 IPublishedCache.GetAtRoot(string?) is obsolete and suggest using IDocumentNavigationQueryService instead.

It seems to return root keys, which I guess should be used to lookup instead.

It seems we can also use ContentAtRoot() from IPublishedContentQuery but unfortunately it didn’t support culture as the underlying GetAtRoot() : Allow `ContentAtRoot()` to accept culture by bjarnef · Pull Request #20129 · umbraco/Umbraco-CMS · GitHub

It seems there are a few different other options:

  • Use GetByIdfrom IPublishedContentCache as Andy’s example here: URL Segment Customisation with Umbraco 15.4
    It seems it need to do multiple lookups though - not sure why an GetByIds() isn’t available?
  • Use Content() from IPublishedContentQuery which support multiple ids.
  • Use ContentAtRoot() from IPublishedContentQuery which isn’t obsolete, but doesn’t support requesting a specific culture as the old GetAtRoot()

What are best practice to get root node(s) without knowing ids?