Views: 1820
Number of votes: 2
Average rating:

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

Please login to comment.