score:2
Accepted answer
what about this:
var range = mycontext.performanceranges
.singleordefault(e=>e.lowthreshold <= score && e.highthreshold >= score)??
performanceranges.single(
e=>e.highthreshold == performanceranges
.max(p=> p.highthreshold)
);
string evaluationtext = range.description;
the range
query will select the element that matches with the thereshold ranges, and if the value is greater (the first query will return null), it will select the greatest range.
score:1
what about this:
string evaluationtext = mycontext.performanceranges.where
(e =>
(e.lowthreshold <= score
&&
e.highthreshold >= score) ||
(e.highthreshold ==
mycontext.performanceranges.max (
x => x.highthreshold)
&& score > e.highthreshold )
)
.select(eval => eval.description).first().tostring();
Source: stackoverflow.com
Related Query
- LINQ - Return Value From Field With A Max Value if No Rows Found
- DataTable: Get Max Value Using LINQ With Criteria Field (GroupBy)
- How to Deal With Dapper return Key Value pair with Dynamic from LINQ
- How to return rows with max value one column grouped by another column?
- Select Max value from sublist with LINQ
- How can I return a list or enumerable of rows where column value has changed with Linq
- Return Max value with LINQ Query in VB.NET?
- Joint 3 tables in linq and return value of nested table with max id
- select from a list with field name and field value with linq (similar to select command)
- Can't add a new record with an integer value into database by using linq from code C#
- How to take the Max value from a List of object where the same objects exists with many duplicate rows
- How to sum a field for all records and then return the max of all summed records with Linq
- Get value from dynamic field with Linq
- Find a certain value from a source collection in a target collection of different type with linq
- LINQ Query, Return Max Value with Where Clause
- how to select records from multiple table with max count value from one table using Linq in Asp.net MVC C#
- Return Rows with Unique and Duplicate values from dataTable using LINQ
- Get the Value of WPF Listview rows and compare them with database field using Linq query
- Linq to return all rows with the same (lowest) value
- How can I get LINQ to return the object which has the max value for a given property?
- LINQ query to return distinct field values from list of objects
- How to understand the following C# linq code of implementing the algorithm to return all combinations of k elements from n
- LINQ to Entities - How to return a single string value from entity
- ListItemCollection - get text from value with LINQ
- Dynamic LINQ query to get Field value from Database
- LINQ get Max value from list
- How can I get LINQ to return the index of the object which has the max value in a collection?
- Select all rows with distinct column value using LINQ
- Get max attribute value from XML using LINQ
- get distinct rows from datatable using Linq (distinct with mulitiple columns)
More Query from same tag
- How to get value of element via attribute in Linq
- Conditional sum using linq for Or condition
- how to assign a list from xml through linq
- Filtering IEnumerable<T> dataset with T as Dictionary<string, object>
- IF statement inside a LINQ SELECT to include columns
- Group by and Sum for the list is the final aggregate result
- Better way to cleanly handle nested XML with LINQ
- Linq grouping multiple where condition
- Processing lambda query result in C# after performing table join
- Translating SQL to LINQ with Group By and max
- Sending an Entity on email using Mailer ASP.net
- How to add Linq support in SQL CLR
- Why is my LINQ Expression with multiple parameters not compiling?
- LINQ querying different DataSets, based on input parameter
- Custom Matching with Moq
- How to populate a ViewModel object after joining two entities together
- EF4.2 extra left outer join to same table
- Extract words in brackets distinctly and randomized
- How should I change this source into LINQ?
- Which methods to close a compiled query
- Using linq select a multiple price values
- LINQ grouping - get other, not grouped properties
- LINQ extension method help sought
- Linq cannot find inserted record before submitchanges
- WCF Data Services - neither .Expand or .LoadProperty seems to do what I need
- XElement with LINQ Select and optional elements
- C# Linq filter data with ternary expression
- Loop through list and compare previous line to current line. I have a list of account numbers mostly duplicates
- SQL to linq query
- Invalid Argument - Interfaces inherited, as works, implicit casting does not. What gives?