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 have several services or even data repositores that wrap specific document types and folder structures for better code handling. But I'm struggling to get the content as IPublishedContent instead of IContent. I would prefer that because of the caching advantages it provides and we don't have to check if a published version exists.
Am I right that in this case the UmbracoHelper.Content(int id) method is the one to use?
I always start at the top and will look for a specific document types on the first level. That one contains the children the repository requires. So far I've used the content service itself, but that is too slow. Using uQuery directly also calls the database. But using the XPATH variant I think would be the best. The nodes there just again have another interface :)
So what do you think I should take?
The requirements are:
- Published Content only- The content relies within subfolders (for optical structuring)- 200+ elements- I need to sort them after a specific date property (descending)- I only need the latest 5-10 entries
My current query over the content service ist:
IContent summaryContent = ...
contentService.GetDescendants(summaryContent).Where(c => c.HasPublishedVersion() && c.IsMyPage()).OrderByDescending(GetDate).Take(count);
But that one is too slow. The IsMyPage() is just a simple extension method comparing the document type. how could I adapt that to a uQuery? Something like this?
uQuery.GetNodesByXPath("//*[@isDoc and documenttype = 'mypage']")OrderByDescending(GetNewsDate).Take(count);
Thanks for any help :)
Okay i found out that the following existing method already does the XPath translation for me and returns the nodes I want:
And is internally translated into:
But now my questions:
children from a specific node of type MyNodeType
uQuery.GetNode(nodeId).ChildrenAsList.Where(x => x.NodeTypeAlias == "MyNodeType")
I never use IPublishedContent objects, only uQuery, much easier
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted