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 7588647
In Process

The Archive Base Latest Questions

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

I am unable to solve this problem with the LINQ Query. So we have

  • 0

I am unable to solve this problem with the LINQ Query.

So we have the table structure as follows:
Id || bug_category || bug_name || bug_details || bug_priority

I want to group by bug_category first. For each bug_category, I want to in turn group by bug__priority.

So basically I want something like :

bug_category = AUDIO :: No of BUGS –> Critical = 3, Medium = 2 and Low = 7 bugs.
bug_category = VIDEO :: No of BUGS –> Critical = 5, Medium = 1 and Low = 9 bugs.

The below query returns all unique combinations of category AND customer_priority:

(where RawDataList is simply a List of data which has the above mentioned structure )

        var ProceesedData = from d in RawDataList
                      group d by new { d.bug_category, d.bug_priority } into g
                      select new
                      {
                          g.Key.bug_category,
                          g.Key.bug_priority
                      };

The below query returns the category followed by a list of records in that category:

            var ProceesedData = from d in RawDataList
                      group d by d.bug_category into g
                      select new { g.Key, records = g
                      };

But I am unable to proceed further as ProcessedData(the return variable) is an unknown type. Any thoughts on this?

  • 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:58:28+00:00Added an answer on May 30, 2026 at 7:58 pm

    I suspect you want (names changed to be more idiomatic):

    var query = from bug in RawListData
                group bug by new { bug.Category, bug.Priority } into grouped
                select new { 
                    Category = grouped.Key.Category,
                    Priority = grouped.Key.Priority,
                    Count = grouped.Count()
                };
    

    Then:

    foreach (var result in query)
    {
        Console.WriteLine("{0} - {1} - {2}",
                          result.Category, result.Priority, result.Count);
    }
    

    Alternatively (but see later):

    var query = from bug in RawListData
                group bug by new bug.Category into grouped
                select new { 
                    Category = grouped.Category,
                    Counts = from bug in grouped
                             group bug by grouped.Priority into g2
                             select new { Priority = g2.Key, Count = g2.Count() }
                };
    
    foreach (var result in query)
    {
        Console.WriteLine("{0}: ", result.Category);
        foreach (var subresult in result.Counts)
        {
            Console.WriteLine("  {0}: {1}", subresult.Priority, subresult.Count);
        }
    }
    

    EDIT: As noted in comments, this will result in multiple SQL queries. To obtain a similar result structure but more efficiently you could use:

    var dbQuery = from bug in RawListData
                  group bug by new { bug.Category, bug.Priority } into grouped
                  select new { 
                      Category = grouped.Key.Category,
                      Priority = grouped.Key.Priority,
                      Count = grouped.Count()
                  };
    
    var query = dbQuery.ToLookup(result => result.Category,
                                 result => new { result.Priority, result.Count };
    
    
    foreach (var result in query)
    {
        Console.WriteLine("{0}: ", result.Key);
        foreach (var subresult in result)
        {
            Console.WriteLine("  {0}: {1}", subresult.Priority, subresult.Count);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I followed other reslted question but still unable to solve this problem. I want
I have a simple problem, yet i am unable to solve this. Either my
I've done a lot of research on this,but I'm unable to solve this problem.
i am unable to solve this problem and i can´t find any solution elsewhere.
I was wondering if anyone else has figured out how to solve this problem.
Based on some standard web searching, I have narrowed down my problem to this:
I've been unable to match this problem into some canonical one, and I would
I have been struggling with this seeminly easy problem for 48 hours, and I
I was trying to solve this homework assignment but was unable to come up
I simply cannot wrap my head around how to solve this problem and after

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.