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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:53:15+00:00 2026-05-27T05:53:15+00:00

When dynamically adding includes to the entity query i.e. ObjectQuery<Address> oQuery = oAddressingEntitiesContext.Addresses.Include(StreetName); if

  • 0

When dynamically adding includes to the entity query i.e.

ObjectQuery<Address> oQuery = oAddressingEntitiesContext.Addresses.Include("StreetName");

if (sResultOption == "FULL")
{
    oQuery = oQuery.Include("AddressLocation").Include("AddressIdentifiers");
}

IQueryable<Address> oResult = oQuery.Where(oParser.getSearchPredicate());

Is there is a way to determine when looking at query results downstream if the entity has the included AddressLocation & AddressIdentifiers related entities by looking at the Address entity?

Ideally something like “IsLoaded” would be helpful

foreach (Address oAddress in oResult)
{
    if (oAddress.AddressLocation.IsLoaded)
    {
       ...
    }
}

It seems any references to the child related entities cause ef to try to load them, due to the lazy load. (I am receiving an error when accessing the related entity when it wasn’t included that there is already an open datareader ..)

  • 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-27T05:53:15+00:00Added an answer on May 27, 2026 at 5:53 am

    IsLoaded is property available in RelatedEnd class which is base for EntityReference and EntityCollection<...>. EntityObject based entities use these classes to expose information about navigation properties but POCOs don’t. In case of proxied entities you can usually convert collection navigation property to EntityCollection<...> (you still have to turn off lazy loading prior to that operation) but I’m not sure how to get easily EntityReference except digging into ObjectStateEntry and RelationshipManager.

    Anyway your biggest problem is probably the exception when you check the property. This can be solved by two options: either you allow lazy loading to be performed or you turned it off:

    context.ContextOptions.LazyLoadingEnabled = false;
    

    You can call this prior to your checks and lazy loading will not be executed. After your check you can again enable lazy loading.

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

Sidebar

Related Questions

In my application I'm dynamically adding new TdxBarSubItems based off of a SQL query.
I'm dynamically adding ssi includes based on variables and I would like to be
I'm having trouble dynamically adding controls inside an update panel with partial postbacks. I've
I'm dynamically adding a custom user control to the page as per this post
I am dynamically adding an image to a canvas object which was working for
I am dynamically adding labels to a form and I would like to set
I have a flowpanel that I'm dynamically adding usercontrols to. I want it to
How would I go about dynamically adding commas as a user is entering numbers?
I am creating a Rails plugin and it is dynamically adding a method to
I've got a page where I'm dynamically adding elements to a from a series

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.