Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

C# Extend LINQ to Query multiple Dictionaries

Avatar of AndyC1000
AndyC1000 asked on
4 Comments1 Solution801 ViewsLast Modified:

I'm wondering if its possible to extend the following LINQ Query to Query multiple Dictionaries.  I've tried adding a comma followed by the Dictionary name although syntax errors exist.  

The datastores are stored in a List - List<SortedDictionary<DateTime, SortedDictionary<string, double>> >


var query = from d in _dataStore
                            (d.Key >= tempStart) &&
                            (d.Key <= tempEnd)
                        select d.Value;

            var valueQuery = (from sortedDictionary in query
                              let name = n
                              select (from e in sortedDictionary where e.Key == name select e.Value) into query2
                              select query2.Single<double>()
                             .OrderBy(value => value);

            double total = valueQuery.Any() && valueQuery.First() != -9999 ? valueQuery.Sum() : -9999;