score:13
Accepted answer
Sounds like you want to group by ID and then convert to a dictionary, so that you end up with one dictionary entry per ID:
var dictionary = entries.GroupBy(x => x.ID)
.ToDictionary(g => g.Key,
// Find the earliest time for each group
g => g.Min(x => x.Time));
Or:
// Group by ID, with each value being the time
var dictionary = entries.GroupBy(x => x.ID, x => x.Time)
// Find the earliest value in each group
.ToDictionary(g => g.Key, g => g.Min())
Source: stackoverflow.com
Related Articles
- List of objects to Dictionary with distinct keys and selected values
- LINQ: Given A List of Objects, Create a Dictionary with child objects as keys and Parent Objects as Value
- Linq "group by" values in a Dictionary property with a list of keys
- Compare keys of dictionary with values of List and return all the matching values including duplicates
- Getting distinct values from a list of objects with objects
- LINQ query to return distinct field values from list of objects
- LINQ: Getting Keys for a given list of Values from Dictionary and vice versa
- Comparing 2 objects and retrieve a list of fields with different values
- Use of Distinct with list of custom objects
- Getting unique values from a list of objects with a List<string> as a property
- List to Dictionary with incremental keys in one line LINQ statement
- Search dictionary values and return List of keys meeting conditions
- How do I combine the keys and values of a Dictionary into one List using LINQ?
- Use linq expression to filter a dictionary with a list of keys
- How to convert Dictionary to List with mixing of values and keys?
- Compare keys of dictionary with values of another dictionary
- Creating a dictionary with keys representing elements from a list
- How to select all the values of an object's property on a list of typed objects in .Net with C#
- How do I join an array of keys with an array of values to a dictionary without a loop?
- Combining dictionary with possibly repeated keys into another dictionary containing the largest values
- C# how to group List by objects with the same property values
- Distinct values from List of objects
- How to filter list of dictionary values with criteria
- How to get list of keys in a dictionary with group by value with using LinQ
- Initialising a new Dictionary with a List of keys
- Check if dictionary with objects for it's values contains two objects with same property
- Build a new dictionary with concatenated duplicated keys based on values
- Linq - Get all keys from dictionary where all values in the value list are equal to criteria
- How to extract values from a list of dictionaries and group and convert to a single dictionary with Linq?
- c# - list of objects - group by - get distinct values by key - lambda / linq
- Retrieving entities with related tables c# using REST API2
- Can't use .Count() from LINQ on Dictionary
- Linq calculate average,total and compare the result in query
- ASP.NET Site crashing on Cannot cast DBNull.Value to type 'System.Guid'
- Using LinqDataSource with linq to sharepoint for paging
- Multiple on clause from DataTable to DataTable via LINQ
- Building a lambda WHERE expression to pass into a method
- How do i delete Multiple Row of Record in this code
- Put LINQ Query in Method with Property as Parameter
- Linq to entities syntax help, when having two tables
- The result of the expression is always true
- Parent/Children Xml to DTO Object Model with LINQ
- How to return nHibernate entity with nested entity having specific criteria
- generic class for linq / lambda expression
- C# LINQ Lambda multiple group of IEnumerable with Sum()
- Dynamic Linq where clause throws OutOfMemoryException
- XML parsing to get a particular tag value in a list of XElement
- How to add Sub total row and grand total row using linq
- LINQ, convert Dictionary<int, bool> to Dictionary<string, string>
- Entity Framework Core LINQ query with multiple where clauses