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

In range filtering on IEnumerable<int>

Vote:
 

Consider this code to filter search results based on whether they are in the given range or not:

.Filter(x => x.MyFooInt.InRange(0, 5));

Problem: how do I solve the equivalent if MyFooInt is an IEnumerable, that is to check if any of the ints are within the range?

#114034
Dec 03, 2014 10:38
Vote:
 

A possible solution could be to do something like this:

.Filter(x => x.SomeInts.In(Enumerable.Range(0,5)))

where SomeInts is an IEnumerable<int>

#114057
Dec 03, 2014 14:33
Vote:
 

Thank you! This helped alot and works in most cases.

There still is the question what to do when ranges are huge. In some cases you could do a stepped range, perhaps, but in others I'm still looking for a solution.

#114088
Dec 04, 2014 10:49
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.