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

InRange filter, HasFilter property = false

Vote:
 

When applying a Range Filter, using the InRange extension method, the HasFilter property of the Filter is false and the actual filter doesn't apply. My code building the filter is below (x is a VariationContent with a property added called SalePrice, which populates with the price of the variant):

var minPrice = HttpContext.Current.Request.QueryString["price__min"] != null ? double.Parse(HttpContext.Current.Request.QueryString["price__min"]) : 0;
var maxPrice = HttpContext.Current.Request.QueryString["price__max"] != null ? double.Parse( HttpContext.Current.Request.QueryString["price__max"]) : double.MaxValue;

filter.And(x => (x.SalePrice.InRange(minPrice, maxPrice, true, true)));

I've checked the value of minPrice and maxPrice and in the example I'm using they're set at 250 and 399 respectively. Despite that, the result set I'm returned contains variants with a SalePrice of < 250.

Where am I going wrong??

Thanks

#141879
Nov 23, 2015 17:02
Vote:
 

are you actually assigning the value?

Assuming you have a variable named "filter", you should do

filter = filter.And(...)

#141881
Nov 23, 2015 17:31
Vote:
 

Hi Per

   Thanks for the reply. It was the one thing I was missing. I've even done it on all my other filters, how very frustrating!

Thanks!

#141887
Nov 24, 2015 8:32
Vote:
 

No problem :-)

#141888
Nov 24, 2015 8:36
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.