src/Shared/EntityFramework/Core/Objects/Internal/LazyLoadBehavior.cs
// <summary>
// Return an expression tree that represents the actions required to load the related end
// associated with the intercepted proxy member.
// </summary>
// <param name="member"> EdmMember that specifies the member to be intercepted. </param>
// <param name="getEntityWrapperDelegate"> The Func that retrieves the wrapper from a proxy </param>
// <returns> Expression tree that encapsulates lazy loading behavior for the supplied member, or null if the expression tree could not be constructed. </returns>
Return an expression tree that represents the actions required to load the related end
associated with the intercepted proxy member.
Return an expression tree that represents the actions required to load the related end associated with the intercepted proxy member .
internal static Func<TProxy, TItem, bool> GetInterceptorDelegate<TProxy, TItem>(
            EdmMember member, Func<object, object> getEntityWrapperDelegate)
            where TProxy : class
            where TItem : class
        {
            Func<TProxy, TItem, bool> interceptorDelegate = (proxy, item) => true;
            Debug.Assert(member.BuiltInTypeKind == BuiltInTypeKind.NavigationProperty, "member should represent a navigation property");
            if (member.BuiltInTypeKind
                == BuiltInTypeKind.NavigationProperty)
            {
                var navProperty = (NavigationProperty)member;
                var multiplicity = navProperty.ToEndMember.RelationshipMultiplicity;
                 For collections:
                  LazyLoadBehavior.LoadCollection(collection, "relationshipName", "targetRoleName", proxy._entityWrapperField)
                 For entity references:
                  LazyLoadBehavior.LoadReference(item, "relationshipName", "targetRoleName", proxy._entityWrapperField)
                 Both of these expressions return an object of the same type as the first parameter to LoadXYZ method.
                 In many cases, this will be the first parameter.
                if (multiplicity == RelationshipMultiplicity.Many)
                {
                    interceptorDelegate = (proxy, item) => LoadProperty(
                        item,
                        navProperty.RelationshipType.Identity,
                        navProperty.ToEndMember.Identity,
                        false,
                        getEntityWrapperDelegate(proxy));
                }
                else
                {
                    interceptorDelegate = (proxy, item) => LoadProperty(
                        item,
                        navProperty.RelationshipType.Identity,
                        navProperty.ToEndMember.Identity,
                        true,
                        getEntityWrapperDelegate(proxy));
                }
            }
            return interceptorDelegate;
        }
internal static Func < TProxy , TItem , bool > GetInterceptorDelegate < TProxy , TItem > ( EdmMember member , Func < object , object > getEntityWrapperDelegate ) where TProxy : class where TItem : class { Func < TProxy , TItem , bool > interceptorDelegate = ( proxy , item ) => true ; Debug . Assert ( member . BuiltInTypeKind == BuiltInTypeKind . NavigationProperty , " " ) ; if ( member . BuiltInTypeKind == BuiltInTypeKind . NavigationProperty ) { var navProperty = ( NavigationProperty ) member ; var multiplicity = navProperty . ToEndMember . RelationshipMultiplicity ; if ( multiplicity == RelationshipMultiplicity . Many ) { interceptorDelegate = ( proxy , item ) => LoadProperty ( item , navProperty . RelationshipType . Identity , navProperty . ToEndMember . Identity , false , getEntityWrapperDelegate ( proxy ) ) ; } else { interceptorDelegate = ( proxy , item ) => LoadProperty ( item , navProperty . RelationshipType . Identity , navProperty . ToEndMember . Identity , true , getEntityWrapperDelegate ( proxy ) ) ; } } return interceptorDelegate ; }
Return an expression tree that represents the actions required to load the related end
associated with the intercepted proxy member.
Return an expression tree that represents the actions required to load the related end associated with the intercepted proxy member .
// Given the proxy and item parameters, construct one of the following expressions: // // For collections: //  LazyLoadBehavior.LoadCollection(collection, "relationshipName", "targetRoleName", proxy._entityWrapperField) // // For entity references: //  LazyLoadBehavior.LoadReference(item, "relationshipName", "targetRoleName", proxy._entityWrapperField) // // Both of these expressions return an object of the same type as the first parameter to LoadXYZ method. // In many cases, this will be the first parameter.
Expression tree that encapsulates lazy loading behavior for the supplied member, or null if the expression tree could not be constructed.
Expression tree that encapsulates lazy loading behavior for the supplied member or null if the expression tree could not be constructed .
member
EdmMember
EdmMember that specifies the member to be intercepted.
EdmMember that specifies the member to be intercepted .
getEntityWrapperDelegate
Func<object, object>
The Func that retrieves the wrapper from a proxy
The Func that retrieves the wrapper from a proxy