Igor
Igor

Reputation: 115

Using FindPagesWithCriteria in Episerver returns no results

i wonder if someone else has come accross this issue. I am trying to use FindPagesWithCriteria and i am creating my property criteria as like this:

PropertyCriteria dateCriteria = new PropertyCriteria();
dateCriteria.Condition = CompareCondition.GreaterThan;
dateCriteria.Name = "PageStopPublish";                
dateCriteria.Type = PropertyDataType.Date;
dateCriteria.Value = DateTime.Now.ToString();
dateCriteria.Required = true;

so i am trying to find all the pages that are not expired. However, some pages may not have StopPublish property set in which case Datetime.MaxValue should be used. But in this particular case (no StopPublish value set) FindPagesWithCriteria will not return any results. Is there a reason for this or is it a bug? As a workaround, i am returning using PageTypeName criteria and then applying some additional filterin for returned PageDataCollection

Upvotes: 0

Views: 1586

Answers (2)

Johan Kronberg
Johan Kronberg

Reputation: 1086

FindPagesWithCriteria will only give you published pages (and pages that the current user have access to) so having StopPublish as a criteria is not necessary.

FindAllPagesWithCriteria will return all pages, including unpublished pages and pages the current user does not have access to.

Upvotes: 3

tompipe
tompipe

Reputation: 949

EPiServer properties with an empty value are never stored in the database. If you access it from code, it will always be null.

To search for a null property using PropertyCriteria, set the IsNull property to true

Upvotes: 0

Related Questions