src/Shared/EntityFramework/Internal/EntityEntries/InternalEntityEntry.cs
// <summary>
// Gets an internal object representing a navigation, scalar, or complex property.
// This method is virtual to allow mocking.
// </summary>
// <param name="propertyName"> Name of the property. </param>
// <param name="requestedType"> The type of entity requested, which may be 'object' if any type can be accepted. </param>
// <returns> The entry. </returns>
Gets an internal object representing a navigation, scalar, or complex property.
This method is virtual to allow mocking.
Gets an internal object representing a navigation scalar or complex property . This method is virtual to allow mocking .
public virtual InternalMemberEntry Member(string propertyName, Type requestedType = null)
        {
            DebugCheck.NotEmpty(propertyName);
            requestedType = requestedType ?? typeof(object);
            var properties = SplitName(propertyName);
            if (properties.Count > 1)
            {
                return Property(null, propertyName, properties, requestedType, requireComplex: false);
            }
            var memberMetadata = GetNavigationMetadata(propertyName) ??
                                 (MemberEntryMetadata)
                                 ValidateAndGetPropertyMetadata(propertyName, EntityType, requestedType);
            if (memberMetadata == null)
            {
                throw Error.DbEntityEntry_NotAProperty(propertyName, EntityType.Name);
            }
            if (memberMetadata.MemberEntryType != MemberEntryType.CollectionNavigationProperty
                &&
                !requestedType.IsAssignableFrom(memberMetadata.MemberType))
            {
                throw Error.DbEntityEntry_WrongGenericForNavProp(
                    propertyName, EntityType.Name, requestedType.Name, memberMetadata.MemberType.Name);
            }
            return memberMetadata.CreateMemberEntry(this, null);
        }
public virtual InternalMemberEntry Member ( string propertyName , Type requestedType = null ) { DebugCheck . NotEmpty ( propertyName ) ; requestedType = requestedType ?? typeof ( object ) ; var properties = SplitName ( propertyName ) ; if ( properties . Count > 1 ) { return Property ( null , propertyName , properties , requestedType , requireComplex : false ) ; } var memberMetadata = GetNavigationMetadata ( propertyName ) ?? ( MemberEntryMetadata ) ValidateAndGetPropertyMetadata ( propertyName , EntityType , requestedType ) ; if ( memberMetadata == null ) { throw Error . DbEntityEntry_NotAProperty ( propertyName , EntityType . Name ) ; } if ( memberMetadata . MemberEntryType != MemberEntryType . CollectionNavigationProperty && ! requestedType . IsAssignableFrom ( memberMetadata . MemberType ) ) { throw Error . DbEntityEntry_WrongGenericForNavProp ( propertyName , EntityType . Name , requestedType . Name , memberMetadata . MemberType . Name ) ; } return memberMetadata . CreateMemberEntry ( this , null ) ; }
Gets an internal object representing a navigation, scalar, or complex property.
Gets an internal object representing a navigation scalar or complex property .
// This check is used for non-collection entries.  For collection entries there is a more specific // check in the DbCollectionEntry class. // Examples: // If (!SomeStringProp is Object) => okay // If (!SomeFeaturedProduct is Product) => okay // If (!SomeProduct is FeaturedProduct) => throw
None
propertyName
string
Name of the property.
Name of the property .
requestedType
Type
The type of entity requested, which may be 'object' if any type can be accepted.
The type of entity requested which may be ' object ' if any type can be accepted .