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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:05:55+00:00 2026-05-27T19:05:55+00:00

I am using entity framework to retrieve a large dataset. The dataset set has

  • 0

I am using entity framework to retrieve a large dataset.

The dataset set has a parent/child relationship, and I need to bring back the child information at the same time as the parent.

What I am finding is that EF sends one query initially to get the list of parent objects, and then iterates through each parent object and queries the DB for the child information.

So if I have 1000 parent objects, I end up with a total 1001 calls to the DB (once for each parent object, plus the original query that gets the list of parents).

Is there anyway to make EF query this is a more efficient manner? Something like:

SELECT * FROM CHILD_OBJECT_TABLE WHERE PARENTID IN (LIST OF PARENT_IDS HERE)
  • 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-27T19:05:56+00:00Added an answer on May 27, 2026 at 7:05 pm

    How are you performing your query? If you’re using lazy loading, you would experience the behavior you describe. Instead, use the Include function to specify that a particular navigation property (be it a related entity or collection) be loaded as part of the query. Put simply, EF will generate a flattened cartesian product of both relationships, then will properly reinflate the data into a parent-> child relationship when it instantiates your objects.

    For example, if your parent class has a collection property called “Children”, you’d call it like this:

    context.Parents.Include("Children").Where(p=> ...)
    

    Or if you prefer query syntax to extension method syntax…

    from p in context.Parents.Include("Children")
    
    where p ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently using Entity Framework and am running into this issue: The relationship between
We are using Entity Framework 1.0. In some cases we need to explicitly open
I am using Entity Framework & LINQ to retrieve data. I am having a
I'm using Entity Framework with a set of 3 different tables, in a hierarchy.
I'm using ADO.Net Entity Framework and C# to retreive the languages of a destination
Using Entity Framework, I suddenly get this strange error after publishing my asp.net mvc
I'm using Entity Framework O/R mapper from Microsoft and using entity classes (generated classes
I am using Entity Framework with my website. To improve performance, I have started
I'm using Entity Framework in my project, and I have the problem that, once
I'm using Entity Framework for creation of my Data Access Layer and I want

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.