Follow @Lusse3 (137 followers)

Flickr Recent Photos

Nu är det fredagsmyyysLaddning inför knatteliganKräftskivan i full rulle :-)Inför Kräftskiva :-)Ett av många äpplen från vårt äppelträd :-)Fika dags :-)Liams första fotbollsmatch. :-)Liams första tunnelbana åk. Självklart smockfullt. :-)Otrolig trevlig kväll med @plingplongen och hanna. Fast här ser vi lite seriösa ut. :-)Glömt att lägga upp bild på våran fina framsida. :-)Liam kör och ilia övervakar. :-)Soooommar

Categories

FindPagesWithCriteria with PropertyCriteria and PropertyDataType.Boolean set to false

Huge title but pretty much what this post is about.

To optimize your FindPagesWithCriteria, it’s good to be as specific as you can. i.e not use one criteria, get 500 hits back and then just use the top 5 out of those. Anyway, when using a PropertyDataType.Boolean and you want to get back those pages that has this set to “false” you can’t really set the value to “false”. Why? Because when the property is false, it has never been set which makes it null.

Let’s see the code:

PropertyCriteria crit = new PropertyCriteria{
            Condition = CompareCondition.Equal,
            Name = ContentPropertyStrings.Finished,
            Type = PropertyDataType.Boolean,
            Value = "false",
            Required = true
};

The code above won’t give you any hits since there won’t be any property set to false, because those properties are null. What you need to do is what you can see below.

PropertyCriteria crit = new PropertyCriteria{
            Condition = CompareCondition.Equal,
            Name = ContentPropertyStrings.Finished,
            Type = PropertyDataType.Boolean,
            IsNull = true,
            Required = true
};

An old problem but I still get this question from time to time so might aswell post it :)

1 Tweet

2 comments to FindPagesWithCriteria with PropertyCriteria and PropertyDataType.Boolean set to false

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Additional comments powered by BackType