Try our conversational search powered by Generative AI!

Null values and FindPagesWithCriteria method

Vote:
 
Ok, here's the deal. I have two custom properties. I've attached them to pages. Some of the pages have both properties defined, others just one of them (undefined value is NULL in db). Now I want to make a search with FindPagesWithCriteria method and find pages that have the other property defined but with other property undefined. I added two criterias with Required properties to make it an AND search. The first criteria is simple, it just compares string value to another string. But the second part where I need to compare whether the property is defined or not, is a bit trickier. I tried to use "" and null as search values for the undefined value, but it didn't work. The search just seemed to ignore them. There's no method for testing undefined values in CompareCondition and StringCompareMethod classes. I can loop the pages manually and test the properties with each page, but is there a way to do it with FindPagesWithCriteria method?
#12519
Feb 10, 2006 15:43
Vote:
 
Hi The trick is the PropertyCriteria.IsNull Property. Set that to true to find properties which are null. See the code below for a sample. PropertyCriteria criteria = new PropertyCriteria(); criteria.IsNull = true; criteria.Name = "WriterName"; PropertyCriteriaCollection pcc = new PropertyCriteriaCollection(); col.Add(criteria); PageDataCollection pages; pages = Global.EPDataFactory.FindPagesWithCriteria(Global.EPConfig.StartPage, pcc, EPiServer.Security.AccessControlList.NoAccess); That code will return all pages where WriterName is null.
#14416
Feb 10, 2006 16:34
Vote:
 
Ok this is just the thing I was looking for. Jag tackar och bockar.
#14417
Feb 13, 2006 9:10
* 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.