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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:12:36+00:00 2026-05-23T01:12:36+00:00

This is the data I read from database into a datatable. the datatable called

  • 0

This is the data I read from database into a datatable.

enter image description here

the datatable called table is now reshaped.

For every same/distinct UnitType + UnitZoom + MemberZoom I create a new Unit and read the MemberId`s into the MemberListId – this should happen in the Order given by the number of the MemberOrder. Sample data:

Unit1: A B C –> P1,P2
Unit2: 1 2 3 –> P9,P12,P4
Unit3: H23 B10 T15 –>X4,T5,Z3,Y1

My code for now that does not proper sort:

 var groupedCollection = table.AsEnumerable()
                                        .GroupBy(row => new
                                        {
                                            UType = row.Field<string>("UnitType"),
                                            UZoom = row.Field<string>("UnitZoom"),
                                            MZoom = row.Field<string>("MemberZoom"),
                                            MOrder = row.Field<int>("MemberOrder"), 
  // I DO NOT WANT the MemberOrder to be in the Group Key, but later on I use this Property to order by it... 
                                        });         


                var unitCollection = groupedCollection
                                    .Select(g => new Unit 
                                    {
                                        UnitType = g.Key.UType,
                                        UnitZoom = g.Key.UZoom,
                                        MemberZoom = g.Key.MZoom,                                   
                                        MemberIdList = g.Select(r => r.Field<string>("MemberId")).OrderBy(b => g.Key.MOrder).ToList(),
                                    });

                List<Unit> units = unitCollection.ToList(); 
  • 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-23T01:12:37+00:00Added an answer on May 23, 2026 at 1:12 am

    Its ordering by static value for list:

    MemberIdList = g.Select(r => r.Field<string>("MemberId")).OrderBy(b => g.Key.MOrder).ToList()
    

    U should use something like this: OrderBy(b => b.SomeValue)

    it should look like this:

    var groupedCollection = table.AsEnumerable()
                                        .GroupBy(row => new
                                        {
                                            UType = row.Field<string>("UnitType"),
                                            UZoom = row.Field<string>("UnitZoom"),
                                            MZoom = row.Field<string>("MemberZoom") 
                                        });         
    
    
                var unitCollection = groupedCollection
                                    .Select(g => new Unit 
                                    {
                                        UnitType = g.Key.UType,
                                        UnitZoom = g.Key.UZoom,
                                        MemberZoom = g.Key.MZoom,                                   
                                        MemberIdList = g.OrderBy(b => b.Field<int>("MemberOrder").Select(r => r.Field<string>("MemberId")).ToList(),
                                    });
    
                List<Unit> units = unitCollection.ToList();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to copy data from one database into my own database, because i
I am trying to copy data from an old database into a new one,
My application loads lots of data from a database into a complex data structure.
I am trying to read some data from html forms and insert it into
I have a problem. Imagine this data model: [Person] table has: PersonId, Name1 [Tag]
I have a internal website that users log into. This data is saved as
I have this big data-entry sort of page, a table kind of layout using
I have this Javascript data: [{id:123,type:test},{id:154,type:another}] How would you transform that into something so
I need to create a quick and dirty solution to migrate data from database
I am looking for a way to import a datatable from Access into an

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.