Replicated parantherical WHERE clauses with FindPagesByCriteria

Vote:
 

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?

#47681
Feb 08, 2011 17:37
Vote:
 

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.

Frederik

#47682
Feb 08, 2011 21:41
Vote:
 

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

http://world.episerver.com/Templates/Forum/Pages/Thread.aspx?id=47685&epslanguage=en

#47686
Feb 08, 2011 23:21
jo
Vote:
 

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

/johan

#47699
Feb 09, 2011 12:47