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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T16:46:49+00:00 2026-05-14T16:46:49+00:00

I would like to know the best way to populate an object that has

  • 0

I would like to know the best way to populate an object that has a collection of child objects and each child object may inturn have a collection of objects, from database without making multiple calls to the database to get child objects for each object. basically in hierarchical format something like for example a customer has orders and each order has order items. is it best to retrieve the data in xml format (SQL server 2005), or retrieve a dataset by joining the related tables together and then map that the data to the object? thanks in advance for your help.

  • 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-14T16:46:50+00:00Added an answer on May 14, 2026 at 4:46 pm

    There are a lot of variables still there:

    1. Are the child objects of the same type? If so you can select them all at the same time and then set up the parent/child relationships in your object mapping layer.
    2. Can the child objects have children of their own? If the nesting is unlimited, then you can’t get all the data at the same time unless you get all the data.

    You could certainly do a join on all of the customers->orders->order items and break everything up in code, but that seems like that would be a lot of overhead in duplicated parent rows and a lot of work in processing that big mess.

    Trying to avoid doing multiple calls might be a pre-mature optimization. Are you having performance problems with doing too many calls to the database?

    Edit: Based on your comments, you should be able to do one query per hierarchy level:

    Select * from orders 
    where orders.customerid = my_customer_id
    

    –Do some orm mappings and make a list of child object ids–

    Select * from child_order_object 
    where child_order_object_id in (list of child object ids)
    

    –Do some more ORM mapping and link child objects to previous parent objects–

    …

    –Repeat for more levels–

    You should be able to have just one query per relationship level rather than the exploding amount of queries to get just one object by id.

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

Sidebar

Related Questions

I would like to know what's the best way to organize my php project
I would like to know What is the best way to include 3rd party
I would like to know how to use Queue in the best functional way.
I would like to know what is the best, fastest and easiest way to
I would like to know the best way to profile app code on OS
I would like to know the best way of parsing an input where multiple
I would like to know the best way of loading a resource in Java:
I would like to know the best way/correct way to achieve from following layout?
I would like to know the best way to handle and implement session time
I would like to know the best way to accomplish the following task: Using

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.