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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:11:38+00:00 2026-05-28T13:11:38+00:00

Please help me, I am new to EF.Lazy loading for POCO objects doesn’t seem

  • 0

Please help me, I am new to EF.Lazy loading for POCO objects doesn’t seem to be working.

  • My POCO classes are in a sepearte assembly, other than the one one for Data access(i.e DAL)
  • The Data Acess layer simply wraps the calls made to the EF’s object context. Please see the code below

    public FilterMaster GetFilter(long ID)
    {
        FilterMaster entity = new FilterMaster();
        try
        {
            using (var context = new RadarEntities())
            {                
                //context.ContextOptions.LazyLoadingEnabled = false;
                //context.ContextOptions.ProxyCreationEnabled = true;
                entity = context.FilterMasters.SingleOrDefault(filter => filter.ID == ID);
                //context.FilterMasters.Include(
                context.LoadProperty(entity, "SQLQuery");                   
    
            }
        }
    
    • When DAL call is completed, the ObjectContext is lost, and when I tried to fetch the related child objects of the Root POCO class, I get null.
    • I’ve tried explicitly enabling ProxyCreation, EnabledLazyLoading, checked the proxy clases generated are not sealed and all the related properties are marked virtual (as suggested on some other links).
      -As the lazy load was not working, I thought of eagerly loading all the related POCO objects, so tried invoking LoadProperty method, which works.

Q1: Am I Imissing something the lazy loading isn’t working?

Q2: If I want to expelictly load all the related child objects the will have to call the LoadProperty method for all properties or there is any simpler way?

  • 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-28T13:11:39+00:00Added an answer on May 28, 2026 at 1:11 pm

    You are disposing your ObjectContext. This is what is preventing you from using LazyLoading. If you need LazyLoading, the class containing GetFilter should create an ObjectContext when it is created, implement IDisposable, and dispose of the ObjectContext when it is disposed.

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

Sidebar

Related Questions

Please help me to write a trigger that adds new rows to a table.
I am new in CSS so please help me in this problem. I hope
I am quite new to programming, i have a question please help me. (
Please help me understand: print gettype(new CustomerObject()) prints: object (so it is an object)
Please help me understand the following: I create a CharBuffer using CharBuffer.wrapped(new char[12], 2,
Can anyone please help me on adding new contacts in address book and apply
I am very new to RegEx -- so can someone please help me figure
I am new to this website and new to Jquery. So seniors please help
Please help! I am new to the .NET web application development. I have used
Please help me. When i try to create new row in database i receive

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.