November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
Hi,
Episerver Find is the best way to do this but since you are not want to use that then you can use cast method and it will eliminate the items-
Please see this -
IContentLoader _loader = ServiceLocator.Current.GetInstance<IContentLoader>();
IEnumerable<BlogCommentPage> pages = _loader.GetChildren<PageType>(parentPageRef).Cast<BlogCommentPage>();;
int count = pages.Count();
or you can refer below article but that is not recommended way to do this -
http://joelabrahamsson.com/get-child-pages-filtered-by-page-type/
I believe you can try to use to find pages with criteria (please google it, I cant paste a link). I think there should be a way of getting pages by parent ID.
If it will not work, I think only caching is something that can improve the performance for your query.
I don't know your particular use case, so this may or may not work for you.
A totally different approach would be to have a hidden field on the parent page itself. A scheduled job can run daily/hourly and can populate this field for you. That way you are forcing the CMS do the work for you than putting the onus on the front-end users. Again - not sure if this is the right approach without knowing your particular use case.
Good idea, but it also can be improved by using published event instead of job.
I'd like to get the count for a specific page type under a specific parent page. I tried using the below. But I think it's resource heavy when comes to only getting the count. (Assume we have thousands of pages and I need to get just the count without returning all the pages).
Is there a way we could only return page count with good performance?
Note: Episerver Find is not preferred.