score:6
Accepted answer
you can try this with a pair of groupby
and a pair of calls of todictionary
, like this:
var res = list
.groupby(v => v.id)
.todictionary(
g => g.key
, g => g.groupby(v => v.start_date.date)
.todictionary(h => h.key, h => h.seelct(x => x.id_owner).distinct().count())
);
if you would like to also add the total time per day, you can do this:
var res = list
.groupby(v => v.id)
.todictionary(
g => g.key
, g => g.groupby(v => v.start_date.date)
.todictionary(h => h.key, h => new {
count = h.seelct(x => x.id_owner).distinct().count())
, totaltime = h.sum(h => x.end_date-x.start_date)
}
);
Source: stackoverflow.com
Related Query
- Transfor List to Nested Dictionary using linq C#
- Add objects to a List nested inside a Dictionary using LINQ extensions
- How to sort a List using a nested Dictionary in Linq C#?
- Convert list to dictionary using linq and not worrying about duplicates
- Convert dictionary values to list using linq
- C# LINQ - convert nested dictionary to a list
- Sort a list and all its nested objects using LINQ
- Convert a list to a dictionary and sum up values using linq
- List of Dictionary to List<Type> using Linq
- Converting list with nested list to a separate list using Linq
- Get a count list of a nested list using LINQ
- Return list with more than one value stored in a dictionary using linq
- Should I be using a Dictionary or List with a linq search?
- List of EF objects to Dictionary of lists using linq
- How to iterate a list returned from a Dictionary using Linq and C#
- Create a nested list from a flat list using Linq
- Using LINQ to build a Dictionary from a List of delimited strings
- How to Filter Nested Collection within Dictionary using LINQ C#
- Filtering List based on a nested list using LINQ
- How to get list of keys in a dictionary with group by value with using LinQ
- How to populate a nested List Class using linq
- c# linq join three list to nested dictionary
- update list property using linq join on dictionary
- List of Arrays to single Dictionary using LINQ
- get values from nested Dictionary using LINQ. Values of Dictionary are list of lists
- Find last record in nested list using linq
- Creating object with nested object list using LINQ to Entities
- How can I filter a nested dictionary using LINQ in C#?
- How to get a child nested list within a record using EFCore Linq
- How to sort a List with LINQ using Nested Property
More Query from same tag
- Cannot implicitly convert type 'System.Collections.Generic.List<AnonymousType#1>' to 'System.Collections.Generic.IEnumerable
- Linq How to Get Average When all values equals null or 0 ? MVC
- Defining correct ids for new bookmarks in OpenXML document
- Is there any way to rewrite this query to be more "LINQ-ier"?
- Linq to Entity Join table with multiple OR conditions
- Linq OrderBy to group objects with the same sets
- dynamically build select clause linq
- dataset to List<T>using linq
- IDataRecord reader gets closed when calling Linq.First()
- Conversion directly in LINQ query
- Linq Expression Builder datetime.year compare
- Linq simple query improvement
- how to set IDENTITY_INSERT as ON?
- Why FirstOrDefault get this exception? Sequence contains no matching element exception
- How to get linq to produce exactly the sql I want?
- ASP.NET LINQ query for filter and loop through multiple tables
- Is it possible to use Linq to group by changes in a series rather than simply by matching on a group item?
- EF4: Get EntitySet specified as string
- querying datatable using linq and c#
- LINQ find average from CSV objects
- Moving specific elements after others but not to top or bottom
- Grouping in LINQ to Entity Model
- How can I combine data from rows in a list using LINQ?
- ASP.Net - using linq to sql as my data layer?
- MongoDB - Unsupported filter contains in linq. How to use contains and ToLower in linq query?
- LINQ over WCF Service (DomainService)
- Return 2 properties from a list using lambda ID(distinct) and the count of the specific ID?
- Comparing two fields using LINQ
- Entity framework Include command - Left or inner join?
- Using linq to filter observablecollection by textbox prevents english typing