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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:23:52+00:00 2026-06-17T15:23:52+00:00

I am using lazy loading to load information about the support ticket which a

  • 0

I am using lazy loading to load information about the support ticket which a ticket message belongs to.
TicketMessage is the child of Ticket. In my TicketMessage class I have the following code to lazy load the Ticket object when the Ticket property of the TicketMessage object is referred to:

// Lazy loading of Ticket object
private Ticket _Ticket { get; set; }
public Ticket Ticket
{
    get
    {
        return this._Ticket ?? (this._Ticket = new Ticket(TicketID, ClientID, ConnectionString, Person.PersonID));
    }
}

However I am experiencing behaviour that indicates that this object is being every time the TicketMessage class is instantiated, thus resulting in some unwanted null reference exceptions. Is there anything blatantly wrong with my lazy loading pattern?

  • 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-17T15:23:53+00:00Added an answer on June 17, 2026 at 3:23 pm

    I would say your NRE problem is more likely to be Person being null rather than an issue with the null-coalescing operation.

    That being said, I don’t particularly like the idea of doing an assignment in that way. From a readability point of view it would be much clearer written as:

    private Ticket _ticket;
    ...
    public Ticket Ticket
    {
        get
        {
            if (this._ticket == null)
            {
                this._ticket = new Ticket(TicketID, ClientID, ConnectionString, Person.PersonID);
            }
            return this._ticket;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to load images in a grid view using lazy loading. I have
I'm using Mika Tuupola's Lazy Load plugin http://www.appelsiini.net/projects/lazyload to delay loading images as you
In Entity Framework 4, what is the difference between Lazy Loading, and using Load()
I'm using Lazy Loading List in my application and I need to load only
I'm using EF4.3, POCOs, Lazy Loading and the IValidatableObject interface. I have a loan
I have two entities on a context for which I've enabled Lazy loading. I'm
I have a class (Foo) which lazy loads a property named (Bar). What is
I am using lazy load jquery plugin . It tells me to put this
What are the implications of the using the Lazy<T> class and marking isThreadSafe: false
If I declare lazy attribute in perl class using Moose, and the attribute is

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.