Check if property can be lazy loaded/is available without having to catch
an exception
Basically I want to enable my foreign key properties to be loaded when
needed even though the original context has been disposed.
I thought about editing the properties getters:
if (Author==null)
{
//load the author userprofile in a new dbcontext
Author = loadedAuthor;
}
return Author;
(Author is a foreign key property in the entity).
However every time I even attempt to check if the property is null it
throws the following exception:
The ObjectContext instance has been disposed and can no longer be used for
operations that require a connection.
Is there no way to check if the property is "locally available" without
having to catch an exception?
No comments:
Post a Comment