I have a method looking like this: IList<AnnouncementPage> GetAnnouncements(AnnouncementType announcementType);
In the end of the method I want to get some pages (of the type AnnouncementPage) from a container.
If I do like this its all good except that I might get some other pages in that container aswell that is NOT an AnnouncementPage:
var announcements = _contentRepository.GetChildren<AnnouncementPage>(announcementContainer);return announcements.OrderByDescending(a => a.Changed).ToList<AnnouncementPage>();
So instead I tried using FindPagesWithCriteria:
var announcements = queryService.FindPagesWithCriteria(announcementContainer, criterias);
The problem now is that this return a PageDataCollection which I dont want. I want a generic list as i got before. I have tried .ToList<AnnouncementPage>() but that didn't work. Of course i can loop through the PageDataCollection and one by one put them in a generic List. But then its unneccessary to even use FindpagesWithCriteria.
So my question is: Is there a way to use FindPagesWithCriteria and get a generic list instead so I can use my strongly typed pages and not PageData objects.
You could use something like this maybe:
var pdc = DataFactory.Instance.GetChildren<AnnouncementPage>(announcementContainer);
var somelist = pdc.OfType<AnnouncementPage>().ToList();