November Happy Hour will be moved to Thursday December 5th.

Checking PageCategory.IsEmpty using PropertyCriteria

Vote:
 

I'm trying to write a PropertyCriteria that excludes any pages where the PageCategory property is empty. There is a property that indicates if it is or not

var searchCriteria = new PropertyCriteria
{
    Condition = CompareCondition.Equal,
    Value = locator.ContentTypeRepository().Load().ID.ToString(CultureInfo.InvariantCulture),
    Type = PropertyDataType.PageType, //what to search for
    Name = "PageTypeID", //the property we want to match against
    Required = true //if this is set to false it will work like OR
};

var categoryCriteria = new PropertyCriteria
{
    Condition = CompareCondition.NotEqual,
    Name = "PageCategory.IsEmpty",
    Value = "true",
    Type = PropertyDataType.Category,
    Required = true
};

var criteria = new PropertyCriteriaCollection { searchCriteria, categoryCriteria };

This doesn't work

Any advice? Thanks

#114645
Dec 16, 2014 23:15
Vote:
 

The following criteria should work:

var categoryCriteria = new PropertyCriteria
            {
                Name = "PageCategory",
                Type = PropertyDataType.Category,
                Value = CategoryList.LoadCategories().ToString(),
                Required = true,
                IsNull = false
            };

This will include only pages with a category

#114770
Dec 19, 2014 22:09
* 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.