Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7588695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:59:10+00:00 2026-05-30T19:59:10+00:00

I would like a method to return a Dictionary of Dictionary from an IQueryable

  • 0

I would like a method to return a Dictionary of Dictionary from an IQueryable formula. Typically,

Dictionary<int, Dictionary<DateTime, string>>

At first, I looked at ToDictionary() of course but couldn’t find a way to declare two one after the other.

Then, i loooked at ToLookup() and I have a way to carry this with a ILookup with the string being my secondary dictionary(the DateTime.Tostring() + the other string)… you follow ? 🙂
But I don’t find the ILookup solution really confortable (parsing a date to string and when i receive the data -> string to date.. beuark)

That would give something like that

return this.ttdc.Trackers.GroupBy(t => new { TrackerTaskId = t.TrackerTaskID, DateGenerated = t.TrackerDateGenerated })
                    .Select(t => new { taskId = t.Key.TrackerTaskId, DateGenerated = t.Key.DateGenerated, count = t.Count() })
                    .ToLookup(k => k.taskId.Value, k => k.DateGenerated.Value.ToString() + "|" + k.count);

Now, i’m thinking about creating a List of self created class with the 3 informations I need as properties.

Could you help me chosing the best pattern ? This method is hosted on a windows service and I would like to limit the amount of data transfered to the client.

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T19:59:11+00:00Added an answer on May 30, 2026 at 7:59 pm

    Here’s an example, using GroupBy and ToDictionary:

    var testValues = new[]{new {ID = 1, Date = new DateTime(2010,1,1), Str = "Val1"},
                           new {ID = 1, Date = new DateTime(2011,2,2), Str = "Val2"},
                           new {ID = 2, Date = new DateTime(2010,1,1), Str = "Val3"}};
    var dict = testValues.GroupBy(item => item.ID)
                         .ToDictionary(grp => grp.Key, 
                                       grp => grp.ToDictionary(item => item.Date, 
                                                               item => item.Str));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to create a method in a base generic class to return
I have a method where I would like to return an object instance of
I have a script with a factory method that I would like to return
What I would like is a method to convert a double to a string
I would like to add a method to a built-in type (e.g. Double), so
I would like to implement the method User.calculate_hashed_password . I'm trying to use the
I would like a low-overhead method of monitoring the I/O of a Windows process.
I would like to write a method in ruby that takes a class with
I would like make an extension method for the generic class A which takes
I would like to create a method that takes an event as an argument

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.