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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:54:14+00:00 2026-05-11T19:54:14+00:00

I have a single table and I need to build a bunch of nested

  • 0

I have a single table and I need to build a bunch of nested objects based on the single table.

Data:

PointA PointB Month Time Price
1 2 11 11:00 10.99
1 2 12 11:00 9.99

Objects are

POINTS {PointA, PointB, Details}
Details {Month, ExtraDetails}
ExtraDetails {Time, Price}

I want to avoid having loads of loops and if statements, so should be able to use linq to do this. but its beyond my linq experience.

edit: These need grouping aswell

any help would be great.

Thanks

  • 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-11T19:54:15+00:00Added an answer on May 11, 2026 at 7:54 pm

    Just tried out a solution:

    var nestedObjects = from row in data
        select new {row.PointA, row.PointB, Details = new {
            row.Month, ExtraDetails = new {
                row.Time, row.Price
            }
        }};
    

    This is assuming that you have already got your data into data.


    Group by

    If you want to group the Points together, you need ‘Group By’:

    var nestedObjects = from row in data
        group row by new { row.PointA, row.PointB } into Points
        select new {
            Points = Points.Key,
            Details = from details in Points
                select new { row.Month, ExtraDetails = new {
                    row.Time, row.Price
                }}
        };
    

    A little more complicated – of course you might want to group by month as well, in which case, you need to follow the same pattern as for the Points bit. Note, this will not create tables, because the group by doesn’t quite do that, but it at least creates the structure for you.

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

Sidebar

Related Questions

I have a simple database named customer with a single table data.I want to
I have a need to build a schema structure to support table of contents
I have a course table which I need to search based on keywords typed
I have a single table of on/off events for different assets. I need to
I'm working on a project that will have a single table holding lots and
I have dbml with single table users i want add partial class for User
I have a single product table with multiple fields which contain user evaluations of
I have a form that searches all rows in a single table (TServices) that
I have a huge access mdb file which contains a single table with 20-30
Let's say you have a database with a single table like... --------------------------------------------- | Name

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.