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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:55:10+00:00 2026-05-15T23:55:10+00:00

When working with Viewmodels from linq to sql I have an architectural problem. When

  • 0

When working with Viewmodels from linq to sql I have an architectural problem.

When you have an object from your db (let’s say “person”), and you load it in your viewmodel. After this in your view, when you try to acces referenced classes (let’s say a person has children object which is a different table in db, and a different datacontext object). You get a “cannot access disposed datacontext object (or something) which is logical, because you loaded your object and disposed the datacontext. for example:

“object” ->foreach(Child child in Model.Person.Children.ToList()){}

But how can you make it so that you can (“preload”?) the children or acces them without having to create a new datacontext, and reload the person in your View ?

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

    Use DataLoadOptions.LoadWith()

    See examples here: http://msdn.microsoft.com/en-us/library/Bb386917(v=VS.90).aspx

    You must specify DataLoadOptions and assign in to the DataContext instance before executing any queries.

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

Sidebar

Ask A Question

Stats

  • Questions 490k
  • Answers 490k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer There's a better way of doing what your code snippet… May 16, 2026 at 9:54 am
  • Editorial Team
    Editorial Team added an answer No, that should be fine. The value in the LIKE… May 16, 2026 at 9:54 am
  • Editorial Team
    Editorial Team added an answer As you are trying to retrieve data in a hasMany… May 16, 2026 at 9:54 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Iam working in c++ .i have an problem while run an application ,which have
I'm working on a WPF application and is using the Model-View-ViewModel pattern. The application
Ok I have the following, set-up and working great. These lines of code should
I am working with a team on LoB application. We would like to have
Im working on a Rails based application where I have the need to allow
I am working on a UserControl , which is composed of a Chart panel
I'm trying to be a better developer... What I'm working with: .Net MVC Framework
The Model-View-ViewModel is very popular with WPF and Silverlight. I've been using this for
I'm working with the MVVM pattern + a simple ServiceLocator implementation, now to my
I'm working on a word processor-type app using the WPF RichTextBox. I'm using the

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.