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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:39:18+00:00 2026-05-14T01:39:18+00:00

UPDATE : from what I’m hearing, I was imagining the problem I describe below.

  • 0

UPDATE: from what I’m hearing, I was imagining the problem I describe below. So, this is pretty much a non-question. Future readers, move on… nothing to see here.


I have an ASP.NET MVC project, much like the NerdDinner tutorial example. (I’m using MVC 2, but followed the NerdDinner tutorial in order to create it).

As per the instructions in part 3 of the tutorial, I’ve created a Linq-to-SQL model of my database by creating a “Linq to SQL Classes” (.dbml) surface, and dropping my database tables onto it. The designer has automatically added relationships between the generated classes based on my database tables.

Let’s say that my classes are as per the NerdDinner example, so I have Dinner and RSVP tables, where each Dinner record is associated with many RSVP records – hence in the generated classes, the Dinner object has a RSVPs property which is a list of RSVP objects.

My problem is this: it appears (and I’d be gladly proved wrong on this) that as soon as I
access a Dinner object, it’s loading all of the corresponding RSVP objects, even if I don’t use the RSVPs member.

First question: is this really the default behavior for the generated classes?

In my particular situation, the object graph contains many more tables (which have an order of magnitude more records), and so this is disastrous behaviour – I’d be loading tons of data when all I want to do is show the details of a single parent record.

Second question: are there any properties exposed through the designer UI that would let me modify this behavior? (I can’t find any).

Third question: I’ve seen a description of how to control the loading of related records in a DataContext by using a DataShape object associated with the DataContext. Is that what I’m meant to do, and if so are there any tutorials like the NerdDinner one that would show not only how to do it, but also suggest a ‘pattern’ for normal use?

  • 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-14T01:39:19+00:00Added an answer on May 14, 2026 at 1:39 am

    When you have a 1:M relationship, the L2S code generator will generate an entity class for the single entity and include an entity set of child objects within the entity. When you retrieve the single (parent) entity, L2S will not retrieve the child objects until you attempt to access the collection of child objects in some way. This is called Lazy Loading. There is no way, that I am aware of, to prevent L2S from retrieving the child objects, other than never attempting to access the collection of child objects. But note, if you never access the child collection, L2S WILL NOT retrieve the child rows. So, since your application is retrieving the child rows, you must be accessing the collection in some way.

    You can also perform what is called ‘eager loading’ by having L2S automatically retrieve the child objects before you attempt to access the collection. However, it doesn’t sound like this is what you want to do.

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

Sidebar

Related Questions

Hi im having an interesting problem. Update: From the comments im getting below this
I am trying to get Update queries from a list of files using this
I have this exact issue ASP.net can’t update page from event handler and it's
I want to execute this command php app/console doctrine:schema:update from the controles without use
(Update - from comments) Question: Is there any advantage of using one extension method
I'm trying to call a row update from php to an mysql database. It
I was just reading an update from a friend's project, mentioning the use of
I have a simple NAnt build file, which attempts to perform an update from
In WinForms, how do I force an immediate UI update from UI thread? What
If I render the update action from inside the create action, is there a

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.