Not an answer to your question, but -
- personally I would just append a filter to the collection/control instead, which in my opinion allows you to write more flexible and exact omittment queries. (Untested and not optimized) example:
for(int i=e.Pages.Count-1; i>=0; i--)
if(e.Pages[i]["MyProp"] != null && e.Pages[i]["MyProp"].ToString().Contains("some text"))
e.Pages.RemoveAt(i);
Regards,
/Marten
I was trying to avoid getting all pages and then testing the results.
I have tried all permutations that I can think of using the IsNull, and the only result I can get is to return all pages where the field is blank, the opposite of what I want. Changing CompareCondition.Equal to CompareCondition.NotEqual does not change the results.
If IsNull is false, then exception "The crieria value cannot be null or empty. Set the IsNull property to search for null." is returned.
--
PropertyCriteria pageCriteria = new PropertyCriteria();
pageCriteria.Condition = EPiServer.Filters.CompareCondition.Equal;
pageCriteria.Required = true;
pageCriteria.Type = PropertyDataType.String;
pageCriteria.Name = fieldName;
pageCriteria.IsNull = true;
--
You could do something like in this post, but that would make your query in the database a horror instead, so there might be a performance impact there instead:
http://world.episerver.com/Forum/Pages/Thread.aspx?id=13184&epslanguage=en
I'm thinking, what happens if you just add a criteria for one character and set Required to false? Will that yield all pages or will it skip the null pages?
I tried the following, which did not return any found pages, the letter "b" does not appear in the "fieldName".
--
PropertyCriteria pageCriteria = new PropertyCriteria();
pageCriteria.Condition = EPiServer.Filters.CompareCondition.Contained;
pageCriteria.Required = false;
pageCriteria.Type = PropertyDataType.String;
pageCriteria.Name = fieldName;
pageCriteria.Value = "b";
pageCriteria.Required = false;
--
I also thought of trying saying that comparison was boolean, in case some text present was treated as true and no text as false, but all variations of CompareCondition.Equals and CompareCondition.NotEquals and pageCriterial.Value of "true" or "false" returned no results.
A less database horror version would be to test for vowels (a, e, i, o and u), as in my case they will be English words so one of these must be present in the word; which is what I am going with for now.