src/Shared/EntityFramework/Core/Objects/Internal/LazyLoadBehavior.cs
// <summary>
// Method called by proxy interceptor delegate to provide lazy loading behavior for navigation properties.
// </summary>
// <typeparam name="TItem"> property type </typeparam>
// <param name="propertyValue"> The property value whose associated relationship is to be loaded. </param>
// <param name="relationshipName"> String name of the relationship. </param>
// <param name="targetRoleName">
// String name of the related end to be loaded for the relationship specified by
// <paramref
//     name="relationshipName" />
// .
// </param>
// <param name="wrapperObject"> Entity wrapper object used to retrieve RelationshipManager for the proxied entity. </param>
// <returns> True if the value instance was mutated and can be returned False if the class should refetch the value because the instance has changed </returns>
Method called by proxy interceptor delegate to provide lazy loading behavior for navigation properties.
Method called by proxy interceptor delegate to provide lazy loading behavior for navigation properties .
private static bool LoadProperty<TItem>(
            TItem propertyValue, string relationshipName, string targetRoleName, bool mustBeNull, object wrapperObject) where TItem : class
        {
             1. Collection is non-null.
             2. ObjectContext.ContextOptions.LazyLoadingEnabled is true
             3. A non-null RelationshipManager can be retrieved (this is asserted).
             4. The EntityCollection is not already loaded.
            var wrapper = (IEntityWrapper)wrapperObject;  We want an exception if the cast fails.
            if (wrapper != null
                && wrapper.Context != null)
            {
                var relationshipManager = wrapper.RelationshipManager;
                Debug.Assert(relationshipManager != null, "relationshipManager should be non-null");
                if (relationshipManager != null
                    && (!mustBeNull || propertyValue == null))
                {
                    var relatedEnd = relationshipManager.GetRelatedEndInternal(relationshipName, targetRoleName);
                    relatedEnd.DeferredLoad();
                }
            }
            return propertyValue != null;
        }
private static bool LoadProperty < TItem > ( TItem propertyValue , string relationshipName , string targetRoleName , bool mustBeNull , object wrapperObject ) where TItem : class { var wrapper = ( IEntityWrapper ) wrapperObject ; if ( wrapper != null && wrapper . Context != null ) { var relationshipManager = wrapper . RelationshipManager ; Debug . Assert ( relationshipManager != null , " " ) ; if ( relationshipManager != null && ( ! mustBeNull || propertyValue == null ) ) { var relatedEnd = relationshipManager . GetRelatedEndInternal ( relationshipName , targetRoleName ) ; relatedEnd . DeferredLoad ( ) ; } } return propertyValue != null ; }
Method called by proxy interceptor delegate to provide lazy loading behavior for navigation properties.
Method called by proxy interceptor delegate to provide lazy loading behavior for navigation properties .
// Only attempt to load collection if: // // 1. Collection is non-null. // 2. ObjectContext.ContextOptions.LazyLoadingEnabled is true // 3. A non-null RelationshipManager can be retrieved (this is asserted). // 4. The EntityCollection is not already loaded. // We want an exception if the cast fails.
True if the value instance was mutated and can be returned False if the class should refetch the value because the instance has changed
True if the value instance was mutated and can be returned False if the class should refetch the value because the instance has changed
propertyValue
TItem
The property value whose associated relationship is to be loaded.
The property value whose associated relationship is to be loaded .
relationshipName
string
String name of the relationship.
String name of the relationship .
targetRoleName
string
String name of the related end to be loaded for the relationship specified by


String name of the related end to be loaded for the relationship specified by
mustBeNull
bool
wrapperObject
object
Entity wrapper object used to retrieve RelationshipManager for the proxied entity.
Entity wrapper object used to retrieve RelationshipManager for the proxied entity .
typeparam
None