I am Continuing my question Previous Question . In my last question @p.s.w.g gives exact solution as i want . Now another situation comes into my mind that suppose we need to search greater then 4
in a condition then what will we do .
Detail
In my last question i said the criteria will goes up to 1-4
, Suppose we include more criteria and give user a option to select 4+
and we will return all data where Bedroom
is greater then four . What we will do in this case .
Suppose i got this in my filter variable var filter = "1,4,4+";
In this condition we should return user all Listings
where Bedrooms are either 1
or 4
or Greater then 4
.
What I Have Tried
var bedCriteria = "1,4,4+";
bedCriteria = bedCriteria .Split(',').ToList();
bool isGreaterThenCriteria = bedCriteria.Contains("4+");
if (isGreaterThenCriteria)
{
query = query.Where(l => l.Place.Bedroom > 4);
bedCriteria.Remove("4+");
}
var minBeds = bedCriteria.Select(int.Parse);
query = query.Where(l => minBeds.Contains(l.Place.Bedroom.Value));