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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:03:53+00:00 2026-06-06T17:03:53+00:00

I have a POCO class that is mostly built through a service. I hit

  • 0

I have a POCO class that is mostly built through a service. I hit the service with some info, get back a dto and use that to build parts of the object. What I’m trying to do is lazy load some of the bigger properties so that they’re only filled on demand. I thought this was the way to do it:

        private List<User> _directReports;
        public List<User>DirectReports
        {
            get
            {
                if (this._directReports == null)
                {
                    SetDirectReports();
                }
                return this._directReports;
            }
            private set
            {
                this._directReports = value;
            }
        }

        private void SetDirectReports()
        {
            using (var client = new ADSClient())
            {
                this._directReports = client.GetDirectReports(this.Guid);
            }
        }

Here’s the problem, and maybe I’m chasing ghosts, but when I step through debugger and look at the guts of the object after instantiating it, those fields have information in it, and it shouldn’t at that stage and completely defeats the purpose of what I’m trying to do. So I’m trying to understand this, am I doing this wrong? Is the compiler running the get method as some point that I’m not thinking about?

  • 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-06T17:03:55+00:00Added an answer on June 6, 2026 at 5:03 pm

    This is a debugger artifact. When you use a watch or a quick inspect to look at the property, the debugger will run the property getter so it can display its value. Which causes your lazy init code to execute. So you’ll never see the property return null.

    Something to keep in mind.

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

Sidebar

Related Questions

I have a POCO: public class Role { public Int32 Id { get; set;
I use MVC 3 and EF 4.3.1. I have my class created with POCO
I have a POCO class that is being sent to the browser as a
Is it possible to have a single POCO class that is made up of
I have two POCO objects: public class Product { public int ProductID { get;
I have a class that is designed primarily as a POCO class, with various
I have an Entity Framework POCO class that is generated by a T4 Template.
Say I have a POCO that stores a date range as follows: public class
I have a POCO class called Attachment that maps to a table in SqlServer
We have POCO, something like: public class Person { public Guid PersonID { get;

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.