v15: New navigation query API, no way to get all content of a specific type with hitting DB #17654
arknu
started this conversation in
Features and ideas
Replies: 1 comment
-
I agree with you. IDocumentNavigationQueryService should be able to delivery the data in TryGetContentKeysOfType without any DB lookups. Until it is available, I guess you can work with an extension method like this public static class NavigationQueryServiceExtensions
{
public static bool TryGetContentKeysOfType(this INavigationQueryService navigationQueryService, string contentTypeAlias, out IEnumerable<Guid> contentKeys)
{
var result = new List<Guid>();
//Add Roots of type
if (navigationQueryService.TryGetRootKeysOfType(contentTypeAlias, out IEnumerable<Guid> keys))
{
result.AddRange(keys);
}
//Add Descendants of type
if (navigationQueryService.TryGetRootKeys(out IEnumerable<Guid> rootKeys))
{
foreach (Guid rootKey in rootKeys)
{
if (navigationQueryService.TryGetDescendantsKeysOfType(rootKey, contentTypeAlias, out IEnumerable<Guid> descendantsKeys))
{
result.AddRange(descendantsKeys);
}
}
}
contentKeys = result;
return true;
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I occasionally used
IPublishedContentCache
like this to find content of a specific type:This uses the cache and does not hit the DB
IDocumentNavigationQueryService
in v15 does not have a method that does this. I would have expected something likeTryGetContentKeysOfType
to exist, but it does not.IDocumentCacheService
does have aGetByContentType
method, but that now hits the DB.Am I missing something here or is this intentional? If so, I find it a bit strange. I can get all kinds of other content from
IDocumentNavigationQueryService
, just not all content of a specific type, not matter where it is located in the tree.Yes, much of the time I'll probably have a root node, in which case this is no problem, but it seems strange to go backwards like this...
Beta Was this translation helpful? Give feedback.
All reactions