Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I know that in Umbraco 7 when the XML-cache was still around the most efficient way to fetch all content nodes by its document type would be something like:
var blogPosts = Umbraco.TypedContentAtXPath("//BlogPost");
But in V8, with NuCache storing the object instances I guessing that a XPath-query would force all nodes to have to "convert" in to XML to perform a query like this? It feels like this could be a performance nightmare?
Also this would perform some nested loop to query lots and lots of objects:
var blogPosts = StartModel.Descendants<BlogPost>()
What I can think of right now would be to use Examine to get all the nodes and then load them from the content cache, but maybe there is a better way?
Anyone who knows what would be the most efficient way to query/load all nodes based on Document Type?
Did you ever find an answer for this?
Seems very relevant even today. Hopefully this post will bring the subject back to life?
Xpath is really only in v8 for use with the Multi node tree picker.
If I remember correctly:
Linq is faster with a smaller amount of content vs Examine (depending on how its used)
Paul Seal and Tim Payne did a talk on this at Umbraco Spark eariler this year the test repo is here -
(you will need to run it to see the results)
I know offroadcode have seen different results in some cases.
EDIT - Slides are on https://umbracospark.com/
I think this will help you.
var blogpost = Model.Root.AncestorOrSelf(BlogPost.ModelTypeAlias);
Does Model.Root have Ancestors?
Do you mean DescendantsOrSelf?
Thanks @Harikrishna, I know that this is an option but also might not be the best option since it will loop over all content in the entire site. In V7 this was quite slow. I guess this would work but I was looking for a solution similar to the one I posted but for V8.
Until then I ended up using Examine to search for all the content and fetch the ones I need from the Content Cache.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted