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

The Archive Base Latest Questions

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

Assuming a typical domain entity approach with SQL Server and a dbml/L2S DAL with

  • 0

Assuming a typical domain entity approach with SQL Server and a dbml/L2S DAL with a logic layer on top of that:

In situations where lazy loading is not an option, I have settled on a convention where getting a list of entities does not also get each item’s child entities (no loading), but getting a single entity does (eager loading).

Since getting a single entity also gets children, it causes a cascading effect in which each child then gets its children too. This sounds bad, but as long as the model is not too deep, I usually don’t see performance problems that outweigh the benefits of the ease of use.

So if I want to get a list in which each of the items is fully hydrated with children, I combine the GetList and GetItem methods. So I’ll get a list and then loop through it getting each item with the full cascade. Even this is generally acceptable in many of the projects I’ve worked on – but I have recently encountered situations with larger models and/or more data in which it needs to be more efficient.

I’ve found that partitioning the loop and executing it on multiple threads yields excellent results. In my first experiment with a list of 50 items from one particular project, I did 5 threads of 10 items each and got a 3X improvement in time.

Of course, the mileage will vary depending on the project but all else being equal this is clearly a big opportunity. However, before I go further, I was wondering what others have done that have already been through this. What are some good approaches to parallelizing this type of thing?

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

    Usually it is faster to make a single database call that returns a set of records.

    This recordset can “hydrate” the top-level objects, then another recordset can load child objects. I’m not sure how your situation does not allow lazy-loading, but this method is essentially lazy-loading, and will surely be faster than making multiple calls to the database that returns a single record each time.

    You could make asynchronous calls to the database so that multiple queries are running in parallel. If you combine this with the first strategy for each “layer” of the model, and write a somewhat more complex hydration function based on multiple-record return sets, you should see that the database handles concurrent connections very well (which is why you see a performance gain from using multiple threads).

    But you don’t need to explicitly create threads – check out the asynchronous methods of a SqlCommand.

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

Sidebar

Related Questions

I understand that a typical .NET application that accesses a(n SQL Server) database doesn't
Assuming that I have this: enum { A = 0x2E, B = 0x23, C
Assuming I have a ASP.NET MVC 3 application that runs in a web farm
Assuming that parsing the equation would not be a problem, how can I make
Assuming that the larger a database gets, the longer it will take to SELECT
Assuming that we have a T myarray[100] with T = int, unsigned int, long
Assuming I have a table with one field called ID that stores 100 different
Assuming I have an Entity Framework 4.2 class like this: class Company { public
Assuming that active directory is set up correctly, I'm trying to find a way
It seems like typical crawlers that just download a small number of pages or

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.