I have a table like this...
ID Description LowThreshold HighThreshold
1 BAD 0.0 .69
2 MEETS .70 .89
3 GOOD .90 2
The object here is to write a LINQ query that will select the right Description based on a given decimal. For instance .75 is between .70 and .89, so it would return “MEETS”. BUT, the kicker is, if the Number is higher than all the ranges, automatically return the Description for the record with the highest HighThreshold. So, if I pass in 5, I should get “GOOD” returned.
I have this so far, but it errors out with scores higher than 2, obviously:
private string GetEvaluationDescription (decimal score)
{
string evaluationText = myContext.PerformanceRanges.Where
(e =>
e.LowThreshold <= score
&&
e.HighThreshold >= score
)
.Select(eval => eval.Description).First().ToString();
}
I'd like to accomplish this with just this one query, but my imagination isn't getting me there. I attempted what I found in this post but couldn't get it to work