Try our conversational search powered by Generative AI!

InRange filter, HasFilter property = false


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??


Nov 23, 2015 17:02

are you actually assigning the value?

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

filter = filter.And(...)

Nov 23, 2015 17:31

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!


Nov 24, 2015 8:32

No problem :-)

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.