Lee Crowe
Oct 10, 2011
  1958
(2 votes)

FindPagesWithCriteriaContext v1.1

Just over a couple of weeks ago I released the FindPagesWithCriteriaContext class.  This essentially provides a nice little Linq wrapper over the top of the FindPagesWithCriteria API, more details can be found here.

The reason for the blog post is that I have added a few new little features to it which some people may be interested in these are shown below.  Basically you can now search for properties that are not properties of the PageData or PageTypeBuilder page type implementation.  This is done by using the new “GetPropertyValue” extension method which accepts a property name and property data type as parameters.

1. Find pages of a specific page type “ImageGalleriesPageType” which contain the text “GalleryOne” within a serialized entity custom property named “ImageGalleryCollection”:

  1: var query = new FindAllPagesWithCriteriaContext<ImageGalleriesPageType>(PageReference.StartPage)
  2:                 .Where(p => p.ImageGalleryCollection.ToString().Contains("GalleryOne"));

2. Find pages of a specific page type “ImageGalleriesPageType” which have a property named “ImageGalleryCollection” with a value of “test”.

  1: query = new FindAllPagesWithCriteriaContext<ImageGalleriesPageType>(PageReference.StartPage)
  2:                 .Where(p => p.GetPropertyValue("ImageGalleryCollection", PropertyDataType.LongString).ToString() == "test");

3. Find pages of a specific page type “ImageGalleriesPageType” which have a property named “ImageGalleryCollection” which contains the text “GalleryOne”.

  1: query = new FindAllPagesWithCriteriaContext<ImageGalleriesPageType>(PageReference.StartPage)
  2:                 .Where(p => p.GetPropertyValue("ImageGalleryCollection", PropertyDataType.LongString).ToString().Contains("GalleryOne"));

4. Find pages of a specific page type “ImageGalleriesPagetype” which have a property named" “ImageGalleryCollection” which is null.

  1: query = new FindAllPagesWithCriteriaContext<ImageGalleriesPageType>(PageReference.StartPage)
  2:                 .Where(p => p.GetPropertyValue("ImageGalleryCollection", PropertyDataType.LongString) == null);

For more details of usage please refer to the previous blog post.

 

Feedback

Feedback as always is greatly received.  If there are bugs/issues please feel free to email or twitter me @croweman and I will do my best to resolve them.

Oct 10, 2011

Comments

Please login to comment.
Latest blogs
Content Delivery API – The Case of the Duplicate API Refresh Token

Creating a custom refresh provider to resolve the issues with duplicate tokens in the DXC The post Content Delivery API – The Case of the Duplicate...

David Lewis | Sep 29, 2022 | Syndicated blog

New Optimizely certifications - register for beta testing before November 1st

In January 2023, Optimizely is making updates to the current versions of our certification exams to make sure that each exam covers the necessary...

Jamilia Buzurukova | Sep 28, 2022

Optimizely community meetup - Sept 29 (virtual + Melbourne)

Super excited to be presenting this Thursday the 29th of September at the Optimizely community meetup. For the full details and RSVP's see the...

Ynze | Sep 27, 2022 | Syndicated blog

Preview multiple Visitor Groups directly while browsing your Optimizely site

Visitor groups are great - it's an easy way to add personalization towards market segments to your site. But it does come with it's own set of...

Allan Thraen | Sep 26, 2022 | Syndicated blog