score:15
Accepted answer
to sum your inner dictionary just do:
dictsum = pt.select(x => x.unitssoldbyyear.values.sum()).sum()
or equally:
dictsum = pt.sum(x => x.unitssoldbyyear.values.sum())
edit:
according to the op comment, this creates a dictionary with the sum by each key:
dictsum = pt.selectmany(kvp => kvp.unitssoldbyyear)
.groupby(kvp => kvp.key)
.todictionary(grp => grp.key,grp => grp.sum(kvp => kvp.value))
Source: stackoverflow.com
Related Query
- How to make a SUM of Dictionary Value nested into a list with LINQ?
- How to get list of keys in a dictionary with group by value with using LinQ
- How to get nested key value pair from dictionary with linq
- LINQ - Convert List to Dictionary with Value as List
- How to implement SkipWhile with Linq to Sql without first loading the whole list into memory?
- LINQ querying nested dictionary with multiple key value selection in C#
- How to select multiple columns from dataset into a string list with LinQ
- Return list with more than one value stored in a dictionary using linq
- Use LINQ to concatenate multiple rows list with same value into single row
- How to get Sum from List in another List as a property with linq
- how to remove half of the dictionary items based on value (DateTime) with LINQ in C#?
- How can I return a list or enumerable of rows where column value has changed with Linq
- Can't add a new record with an integer value into database by using linq from code C#
- How to set a value in one list when comparing it with other list using LINQ
- How to merge two lists while adding metadata indicating value source with LINQ statement?
- C# LINQ how to flatten parent list and two nested children lists into a new list
- C# Linq adding to dictionary with list as value
- How do you LINQ data into ObservableCollection with nested ObservableCollection?
- How to select from a list with Linq based on id and datetime value
- Finding if value exists in list with LINQ and saving info into a dataset, possibly
- How to sort a List with LINQ using Nested Property
- How to filter object list with LINQ without using nested If statement
- How do we use a LINQ query on a Dictionary with a nested object?
- How to split list into LINQ groups and get biggest value in group
- calculate sum of list properties excluding min and max value with linq
- How to get a list of filtered values in Dictionary into a List using LINQ or Lambda?
- How to match value from textbox to dictionary and display it in another textbox on button click with linq query in C#
- How to sort a List using a nested Dictionary in Linq C#?
- How to merge more than one list having objects into one list with sum of one of the elements of the list in c#
- how to compare every value in a list with an other list by linq
More Query from same tag
- Translating datediff LINQ query to SQL with Entity Framework Core and .NET Core 3.1
- C# Linq GroupBy
- simple linq issue, but I can't figure it out
- SQL "IN" CLAUSE Performance issue
- ASP.NET Convert Invalid String to Null
- LINQ search List<string[]>; if [0] matches then return [1]
- conditional check in predicate LINQ
- LINQ Distinct counting duplicates even when the hash codes are the same?
- Linq and sqlclient performance
- Stubbing Code for Test With Linq Expressions and Lambdas
- Entity Framework - Retrieve different values according to foreign keys
- How to get distinct value of Upper and lower case?
- DataContext. Is there a single method where I can add an extra WHERE?
- How to load varbinary(max) fields only when necessary with ADO.NET Entity Framework?
- LINQ version of sql query with multiple left joins, group by, and datetime conversion
- How can I group/sum values in LINQ to XML?
- How to clear default select clause on IQueryable resultset
- c# - using SelectMany to merge multiple lists
- Using linq to filter a list from a list
- Dynamic Linq OR with int and string
- Linq to Entities using incorrect parameters
- How to assign values to array with linq correctly?
- Show Mulitple Files that Meet Criteria, But Select One of Them
- Calling a C# class from my ASPX page
- count of last item of the day
- Better way to do this LINQ query
- Unable to cast object of type '<>f__AnonymousType5`6
- When does a lambda in an extension method do too much?
- Which LINQ query is more effective?
- LINQ WHERE DATE Issue