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 Query
- 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
- Compare keys of dictionary with values of List and return all the matching values including duplicates
- 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
- 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?
- How to convert Dictionary to List with mixing of values and keys?
- Linq "group by" values in a Dictionary property with a list of keys
- How to extract values from a list of dictionaries and group and convert to a single dictionary with Linq?
- How to bind and save an object containing a list of objects to database context in ASP.NET MVC with EF code first?
- Group dictionary by values and return list of keys
- Get keys (objects) from a dictionary that contains list and filtered by values
- Getting distinct values from a list of objects with objects
- Creating a dictionary with LINQ and keys from nested list
- Dicionary intersect keys with list and get in result dicionary with values at the beggining LINQ
- LINQ query to return distinct field values from list of objects
- LINQ Get Distinct values and fill LIST
- Using Distinct with LINQ and Objects
- Use of Distinct with list of custom objects
- Getting unique values from a list of objects with a List<string> as a property
- Convert a list to a dictionary and sum up values using linq
- List to Dictionary with incremental keys in one line LINQ statement
- Merge two Lists in C# and merge objects with the same id into one list item
- Use linq expression to filter a dictionary with a list of keys
- Linq to Dictionary with key and a list
- Compare id's of objects in two lists and get the list of objects that includes objects with ids occurring in both of them
- Compare keys of dictionary with values of another dictionary
- Creating a dictionary with keys representing elements from a list
- C# - Linq optimize code with List and Where clause
More Query from same tag
- LINQ to Entity VB - Convert Long to String for Contains or Like
- Access count of related records of an entity Entity Framework
- Reusable Calculations For LINQ Projections In Entity Framework (Code First)
- The entity or complex type '' cannot be constructed in a LINQ to Entities query, three table outer join
- Query to include non-protected resources only
- Smart and efficient replace with linq in C#
- Appending dynamic where statements in LINQ to Entities but as an OR operator instead of AND
- Convert datetime to date into singleordefault method
- Creating XML from a LINQ result
- LINQ-to-Entities Find DateTime difference
- Batch insert/update with entity framework
- XDocument.Descendants("somethinghere").Count() method does not exist
- Using LINQ in a List
- How add uniqe element from List to ObservableCollection by Linq
- How to use anonymous types with Netflix OData API
- Left outer join in C# LINQ
- How to write this Linq to NHibernate query
- Linq query to return the cheapest product, only if it is unique
- Linq-to-Sql query with group by
- ILASM for Compact Framework?
- Search by Letters using LINQ
- Join and Group in LINQ
- Iterate through a list of objects and find the one with the highest price and set it to Active and disable all others
- How to add Linq support in SQL CLR
- Xml String to object in c# using XDocument
- LINQ: How to search 2 list ( Two list: Entity List and Array ) combined?
- How to convert EPG XML Time to UTC - Silverlight - WP7
- Fluent Assertion: Dictionary Should BeEquivalentTo Excluding Property on Dictionary Value
- LINQ Grouping: Is there a cleaner way to do this without a for loop
- Linq Filtering items with ForEach crashes for large data set