score:3
Accepted answer
You could try something like this:
data.GroupBy(d => new { Hometeam = d.Hometeam, Outteam = d.Outteam })
.Select(g => g.OrderBy(d => d.Status)
.ThenByDescending(d => d.GoalsHometeams + d.GoalsOutteams)
.First())
- Groups by the team combinations
- For each group, finds the entry with the newest status (
Confirmed
comes beforeOpen
in alphabetical order) - If multiple with same status (i.e., multiple
Open
), finds entry with highest combined score. - Grabs the first result (which should be newest) per group.
Demo: http://ideone.com/vlCtw
Sample Result:
Current game status results:
Confirmed, Fylkir, Valur, 3, 1
Confirmed, Selfoss, Grindavik, 3, 3
Confirmed, Keflavik, IBV, 1, 0
Confirmed, Stjarnan, IA, 1, 1
Confirmed, Breioablik, Fram, 0, 2
Source: stackoverflow.com
Related Articles
- Linq distinct by multiple columns and pick the newest row
- Distinct on Multiple Columns Entity Framework LINQ
- LINQ to DataSet, distinct by multiple columns
- LINQ to SQL Select Distinct by Multiple Columns and return entire entity
- C# Linq How to select the distinct row count of multiple columns in a datatable
- LINQ - Return rows with all columns of a table based on multiple distinct columns
- LINQ to Entities multiple columns need 1 to be distinct
- How can I return all the columns of a table using multiple distinct columns in Linq
- Select DISTINCT on a column when selecting multiple columns in Linq
- Linq distinct over multiple columns into dictionary
- LINQ to SQL - Distinct records across multiple columns
- LINQ query returning the entire object grouped by multiple columns when one is distinct
- How to distinct by multiple columns with input parameter in Linq
- C# Linq Group By on multiple columns
- Linq Syntax - Selecting multiple columns
- linq distinct or group by multiple properties
- linq to sql join on multiple columns using lambda
- LINQ - group/sum multiple columns
- Selecting multiple columns with linq query and lambda expression
- how to group by multiple columns using linq
- Dynamic LINQ GroupBy Multiple Columns
- LINQ to SQL: Left join on multiple columns
- Does this LINQ code perform multiple lookups on the original data?
- Linq GroupBy on multiple columns with potentials null value
- c # using linq to group by multiple columns in a datatable
- LINQ COUNT on multiple columns
- How to reuse a linq expression for 'Where' when using multiple source tables
- Linq to SQL select multiple columns
- Group by multiple columns linq count nested row
- LINQ Source Code Available
- LINQ Database
- Add on condition with Lambda
- how to Group By LINQ Query result to DataGridView without looping
- Can you use LINQ extension method operators in an ASP.NET databinding expression?
- Linq query with aggregates
- Selecting items in an ordered list after a certain entry
- Using C# Lambda to split string and search value
- EF Select MAX value that is <= 5
- Get top max item by linq
- Linq To Sql : SQL Default Value overridden
- How to use LINQ to group by and order by certain column
- converting dictionary string string to json string
- What happens if you mix supported and unsupported operators in NHibernate?
- Compare strings with non-English characters?
- Copy one List to another List and SubList with LINQ
- Why do I get "Sequence contains no elements"?
- Group by list of objects as dictionary of int, List of bjects
- Returning datasets from LINQ to SQL in a REST/WCF service
- Filter a List with linq
- How can I fix the performance issue of this linq query?