1

The following code attempts to retrieve an object which is a navigation property for a disconnected graph.

If the property is not loaded an error occurs

The ObjectContext instance has been disposed and can no longer be used for operations that require a connection

Is there a way that I can test whether the property is loaded ?

navProps = GetNavigationProperties(originalEntity);
foreach (PropertyInfo navProp in navProps)
{
   object obj = navProp.GetValue(item);  // fails if the property type is an unloaded collection
   // more code
}
Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
Kirsten
  • 15,730
  • 41
  • 179
  • 318

1 Answers1

0

The answer to this question helped me. I found that if I included

Configuration.ProxyCreationEnabled = false;

in the constructor to my context then navProp.GetValue(item) returns null instead of raising an error

Community
  • 1
  • 1
Kirsten
  • 15,730
  • 41
  • 179
  • 318