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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:29:20+00:00 2026-06-01T16:29:20+00:00

I try to group by StringId and then by Name var a = myList

  • 0

I try to group by StringId and then by Name

var a = myList
                .GroupBy(item => new TcGroupByKey() 
{StringId = item.Id, ChannelName = item.ChannelName}).ToList();

I have created this inner class TcGroupByKey

so I can pass the result to TrackingChannelRow ctor

and will get strongly type argument and not object

 public TrackingChannelRow(ManageTcModel.TcGroupByKey tcGroupByKey,
            IGrouping<ManageTcModel.TcGroupByKey, TrackingChannelItem> subChannels,
            IEnumerable<Manager.TrackingChannels.Model.ToolbarItem> toolbars,
        IEnumerable<Manager.TrackingChannels.Model.BundleItem> bundles)
        {

But the group by doesn’t work.

What am I doing wrong?

  • 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-06-01T16:29:22+00:00Added an answer on June 1, 2026 at 4:29 pm

    I think that what you’re looking for is to group by composite key…

    Something similar to what Marc described in this post Linq to SQL with Group by

    The key is to use ‘anonymous’ types – not the named one like you did – that LINQ can translate into SQL, otherwise there’s an issue and that code can only run ‘post SQL’ (so you enumerate first then group but lose on the SQL integration, performance).

    So, in your case it’d be something like this…

    new {StringId = item.Id, ChannelName = item.ChannelName}
    

    …instead of new TcGroupByKey() {StringId = item.Id, ChannelName = item.ChannelName}

    There is similar problem with doing a ‘Select’ into anonymous (works) or named type (doesn’t – unless, as I mentioned above, you separate the SQL and C#-only expressions part, a bit simplified).

    hope this helps

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

public ActionResult Create() { try { var Group = GroupRepository.FindAllGroups(); ViewData[Group] = GroupRepository.FindAllGroups(); ViewData[Feature]
When I try to code as this, XPathNodeIterator it; string selectStr = Equipment/Group/item; it
If I try: List<Student> students = new List<Student>(); List<Group> Groups = new List<Group>(); Groups
I am using MongoDB v1.4 and the mongodb-csharp driver and I try to group
I keep getting this error when I try to commit a group of executed
my popUpButton is in a window with a group of popUpButtons. If I try
I have this code for update: public Boolean update() { try { data.put(ContactsContract.Groups.SHOULD_SYNC, true);
Try to see which cast is faster (not necessary better): new c++ case or
My Rails application have a User model and a Group model, where User belongs
I am getting java.util.concurrentmodificationexception for my implementation below try{ Date fromDate = new Date().parse(yyyy-MM-dd,

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.