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 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

Related Questions

I have a DatePicker working on a View which also has a ViewModel associated
Hi people stackoverflow. I'm working with MVVM, I have ViewModel call UserViewModel with a
I'm an inch away from getting my Create form working. My problem is that
I have a Domain object called User and UserCreateViewModel.Automapper is used for mapping from
I'm new to Linq and have not been able to get this working. public
Working with Reporting Services 2008 r2. So here's my issue: We have 5 reports
Ok I have the following, set-up and working great. These lines of code should
I am working in ASP.NET 3.5 MVC application. We have a functionality where we
I have an index page for listing products. From this page I would like
I am working with a team on LoB application. We would like to have

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.