Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more

Searching for pages with any value in property

Vote:
 

How do I search for pages with any value in a given property? I can do a search for pages with a specific value in the property, but I can't figure out how to search for "not empty".

For example, this doesn't work:

var criterias = newPropertyCriteriaCollection
{
  new PropertyCriteria()
  {
    Condition = CompareCondition.NotEqual,
    Name = "MyProperty",
    IsNull = false,
    Type = PropertyDataType.String,
    Value = ""
  }
};

var pages = DataFactory.Instance.FindPagesWithCriteria(PageReference.StartPage, criterias);

An exception is thrown, "The crieria value cannot be null or empty. Set the IsNull property to search for null."

Any ideas?

#56205
Jan 12, 2012 7:22
Vote:
 

This cannot be achived with just FindPagesWithCriteria and PropertyCriteria. You have to use a filter afterwards. See http://www.frederikvig.com/2009/05/episerver-filter-part-1/. Or just a loop.

 

You can do the other way around, search for properties that is null.

#56213
Edited, Jan 12, 2012 10:04
* 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.