An EPiServer frustration for me is not being able to grab a 'deep' tree as a PageDataCollection. Sometimes I want to be able to iterate through a collection of all descendants of a page.
Ideally I'd want to do a GetChildren with a 'deep' boolean parameter or something, but there isn't one. Trying to use FindPagesWithCriteria is frustrating as if you enter no Criteria then it returns nothing.
For now, I've just hacked it with the following code. It works, but I hate it. If you have a better solution please let me know. And yes, I know that I could iterate through GetChildren but that would be lots and lots of separate API calls and I really don't want to take that hit. I want a one-time API hit.
1: PropertyCriteriaCollection oColl = new PropertyCriteriaCollection();
2: PropertyCriteria oCrit = new PropertyCriteria();
3:
4: oCrit.Condition = EPiServer.Filters.CompareCondition.GreaterThan;
5: oCrit.Name = "PageStartPublish";
6: oCrit.Value = DateTime.Parse("1/1/1900").ToString();
7: oCrit.Type = PropertyDataType.Date;
8:
9: oColl.Add(oCrit);
10:
11: PageDataCollection oChildPages = DataFactory.Instance.FindPagesWithCriteria(oPageData.PageLink, oColl);