Try our conversational search powered by Generative AI!

In range filtering on IEnumerable<int>


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?

Dec 03, 2014 10:38

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>

Dec 03, 2014 14:33

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.

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.