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

  • Home
  • SEARCH
  • 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 8697251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:28:42+00:00 2026-06-13T01:28:42+00:00

I am working on a small project using C# and EF5.0 and I need

  • 0

I am working on a small project using C# and EF5.0 and I need to group some data. Let say I have table of columns in a building like shown below.

+----------+--------Columns Table--+------+------+
| ColumnID |ColumnName|Width|Length|Height|number| 
+----------+----------+-----+------+------+------+
|        1 |   C101   |  50 |   70 | 250  | 1    |  
|        2 |   C102   |  70 |   70 | 250  | 1    |    
|        3 |   C103   |  70 |   60 | 250  | 1    |    
|        4 |   C104   |  90 |   70 | 250  | 1    |     
|        5 |   C105   |  40 |   50 | 250  | 1    |     
|        6 |   C106   |  50 |   70 | 250  | 1    |    
|        7 |   C107   |  50 |   60 | 250  | 1    |    
|        8 |   C108   |  70 |   70 | 250  | 1    |     
+----------+----------+-----+------+------+------+

I need a C# code to see the above data groupped like this:

+----------+---Groupped Columns Table-----+------+
|G_ColumnID|ColumnName|Width|Length|Height|number| 
+----------+----------+-----+------+------+------+
|        1 |C(101-106)|  50 |   70 | 250  | 2    |  
|        2 |C(102-108)|  70 |   70 | 250  | 2    |    
|        3 |   C103   |  70 |   60 | 250  | 1    |    
|        4 |   C104   |  90 |   70 | 250  | 1    |     
|        5 |   C105   |  40 |   50 | 250  | 1    |         
|        6 |   C107   |  50 |   60 | 250  | 1    |            
+----------+----------+-----+------+------+------+

I prefer clues than the exact solution.

EDIT : Below code shows my current state. I think I can find the columns with the same Height, Width and Length using this code. But I am not sure how to generate a new name for the group.

using (pehlivanEntities context = new pehlivanEntities())
{           
     foreach (var item in context.table1)
     {               
          int id = item.ColumnID;
          foreach (var item2 in context.table1)
          {
               int id2 = item2.ColumnID;
               if (id != id2)
               {
                   if (item.Width == item2.Width)
                   {
                       if (item.Length == item2.Length)
                       {
                            if (item.Height == item2.Height)
                            {
                               //Alter item.ColumnName
                               //increase item.number by one
                               //Remove item2
                            }
                       }
                   }
               }
          }
     }
}
  • 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-13T01:28:44+00:00Added an answer on June 13, 2026 at 1:28 am

    Well you’d start with grouping on a composite key:

    var groups = myData.GroupBy(d => new{d.Width, d.Length, d.Height})
    

    then

    groups
     .Select(g => new {
        g.Key.Width, 
        g.Key.Length, 
        g.Key.Height, 
        columnNames = g.Select(x => x.ColumnName),
        number = g.Count()})
    

    then a bit of string manipulation on the columnNames field

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

Sidebar

Related Questions

I am working on a small project and I need some help. I have
i am working on a small project that i need the ability to let
i'm working on a small project that might have an additional coder at some
I am currently working on a small personal multiplayer game project. I am using
I'm new to objective C and currently working on a small project. I have
I'm working on a small uni project where I have a program for a
I'm working on a small project for myself at the moment and I'm using
I'm working on a small project, and need to implement internationalization support somehow. I
I'm currently working on a small project in java where I need to process
I am doing a small project using JPA. I need to insert the employee

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.