Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Replicated parantherical WHERE clauses with FindPagesByCriteria


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:

    (cat_id = 1 OR cat_id = 2)
    (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?

Feb 08, 2011 17:37

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.


Feb 08, 2011 21:41

I've posted a question about Linq2Pages support in R2, would be pretty sweet to see it supported!

Feb 08, 2011 23:21

Unfortunately, Categories are one of the things that Linq2Pages currently doesnt support...


Feb 09, 2011 12:47
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.