1
Vote

ObjectHolder is marked 'IsLoaded' while the related object is not loaded.

description

I think I found a bug in the ObjectHolder<T> class (ObjectHolder_1).
When OPF3 is trying to load a relation by calling 'InnerObject' and ObjectHolder does not (yet) has a ObjectContext.
That object cannot (is not) loaded.
But.. the IsLoaded properties is set to true.
 
Old code:
if(!IsLoaded )
{ InnerLoad(this.ObjectContext);
Tracing.Current.TraceStorageIO("Loaded persistent's related objects from storage.");
// Set the ObjectSetHolder as loaded.
IsLoaded = true;
}
 
My fix:
if(!IsLoaded && this.ObjectContext != null)
{ InnerLoad(this.ObjectContext);
Tracing.Current.TraceStorageIO("Loaded persistent's related objects from storage.");
// Set the ObjectSetHolder as loaded.
IsLoaded = true;
}
 
 
If tested this and found problems with it.
But, I'm not sure if Christian has his own reasons to set IsLoaded to true while the ManagedObject == null.
I did not use
'IsLoaded = (ManagedObject != null)'
because maybe there is no relation added (allows null).
 
Greetings
Peter

comments