What's the trick to doing parenthetical-like queries with FindPagesByCriteria? In my case, I need pages from one of two categories that also match one of two page types.
In fake SQL terms, I need something like this:
WHERE (cat_id = 1 OR cat_id = 2) AND (page_type = "Text Page" OR page_type = "News Article")
I can't figure out how to do this by juggling the "Required" property on the PropertyCriteria object. What I need is two different PropertyCriteriaCollections -- one for the category and one for the page type. The criteria in each would be required=false (because it could be one category OR the other), but between the two collections, they both have to evaluate to true.
It's weird, I know. Any way to do this?
You could use FindPagesWithCriteria with the categories as criterias and then us the Where extension method on the PageDataCollection to filter out the pages that are of the correct page type. You can also take a look at Querying EPiServer PageData using LINQ.
Hope this helps.
I've posted a question about Linq2Pages support in R2, would be pretty sweet to see it supported!
Unfortunately, Categories are one of the things that Linq2Pages currently doesnt support...
you could use something like this,