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 ..)