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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:37:45+00:00 2026-06-04T02:37:45+00:00

Ok! I have to say both technology are great. Although there seems that something

  • 0

Ok!

I have to say both technology are great. Although there seems that something I do not get it.

You have a data in you database (and let say you want to show data from a table that has references to other tables).

I have a model with List or IEnumerable or IQueryable or whatever…

So in my view I want do foreach through the list of object and take advantage of cool feature of references to other tables. No problem in controller while you are in

using (var datatabse = new MyEntity)
{
}

But when you get out of using db has disposed and you get common error The ObjectContext instance has been disposed and can no longer be used for operations that require a connection.

So i do not see other options as creating in memory copies of entity objects…but you loose all cool EF4 references and you have to manually load data first in your model and then with foreach show it on the view.

So instead of List<(EF4Type)> or IEnumerable<(EF4Type)> or IQueryable<(EF4Type)>

you have to do List<(MyCustomHelperClass)> where MyCustomHelperClass represents a class with properties similiar to entity objects and probably some additional beacuse you do not have access to properties of referenced tables Then you have to do foreach and Load data into this List and the another @foreach on the view with Razor to show all.

Twice as much work and if project is big…you can see a bigger picture of how manny those helperClasses you need. Was all this cool new technology really meant to be used in that way?….or am I missing something.

  • 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-06-04T02:37:46+00:00Added an answer on June 4, 2026 at 2:37 am

    You are probably getting that error when you reference a lazy loaded property in your view. You should eager load everything you need in the Controller before passing it to the View.

    See Loading Related Objects (Entity Framework).

    The following example will cause all courses to be retrieved with the departments in the same query. This is eager loading.

    // Load all departments and related courses
    var departments1 = context.Departments                           
        .Include(d => d.Courses)                           
        .ToList();
    

    Without the Include() part, courses could be retrieved later (possibly after your context has been disposed in the view). This is called lazy loading.

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

Sidebar

Related Questions

Let's say that I have a Company model and a Product model, both of
Let's say I have both the Production and Sandbox environments. There are differences between
Let's say you have this scenario:a simple blog home-page that loads both static content
Say you have 2 share libraries, lib1.so and lib2.so, that both have libcommon.a statically
I have an Access database. Let's pretend it's for a pet store. There's a
Is there any way to have 2 Div Elements side by side, let's say
Lets say I have classA which contains classB and both are [Serializable]. I assumed,
lets say I have two methods in my controller to support both json and
Lets say i have at least two lua script files. test1.lua test2.lua both define
Say you have two classes, A and B. Is it possible to instantiate both

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.