src/Shared/EntityFramework/Core/Mapping/Update/Internal/ExtractorMetadata.cs
// <summary>
// Requires: record must have correct type for this metadata instance.
// Populates a new <see cref="PropagatorResult" /> object representing a member of a record matching the
// type of this extractor. Given a record and a member, this method wraps the value of the member
// in a PropagatorResult. This operation can be performed efficiently by this class, which knows
// important stuff about the type being extracted.
// </summary>
// <param name="stateEntry"> state manager entry containing value (used for error reporting) </param>
// <param name="record"> Record containing value (used to find the actual value) </param>
// <param name="useCurrentValues"> Indicates whether we are reading current or original values. </param>
// <param name="key"> Entity key for the state entry. Must be set for entity records. </param>
// <param name="ordinal"> Ordinal of Member for which to retrieve a value. </param>
// <param name="modifiedPropertiesBehavior"> Indicates how to determine whether a property is modified. </param>
// <returns> Propagator result describing this member value. </returns>
record must have correct type for this metadata instance.
Populates a new  object representing a member of a record matching the
type of this extractor. Given a record and a member, this method wraps the value of the member
in a PropagatorResult. This operation can be performed efficiently by this class, which knows
important stuff about the type being extracted.
record must have correct type for this metadata instance . Populates a new object representing a member of a record matching the type of this extractor . Given a record and a member this method wraps the value of the member in a PropagatorResult . This operation can be performed efficiently by this class which knows important stuff about the type being extracted .
internal PropagatorResult RetrieveMember(
            IEntityStateEntry stateEntry, IExtendedDataRecord record, bool useCurrentValues,
            EntityKey key, int ordinal, ModifiedPropertiesBehavior modifiedPropertiesBehavior)
        {
            var memberInformation = m_memberMap[ordinal];
            int identifier;
            if (memberInformation.IsKeyMember)
            {
                Debug.Assert(
                    null != (object)key, "entities must have keys, and only entity members are marked IsKeyMember by " +
                                         "the metadata wrapper");
                var keyOrdinal = memberInformation.EntityKeyOrdinal.Value;
                identifier = m_translator.KeyManager.GetKeyIdentifierForMemberOffset(key, keyOrdinal, ((EntityType)m_type).KeyMembers.Count);
            }
            else if (memberInformation.IsForeignKeyMember)
            {
                identifier = m_translator.KeyManager.GetKeyIdentifierForMember(key, record.GetName(ordinal), useCurrentValues);
            }
            else
            {
                identifier = PropagatorResult.NullIdentifier;
            }
            var isModified = modifiedPropertiesBehavior == ModifiedPropertiesBehavior.AllModified ||
                             (modifiedPropertiesBehavior == ModifiedPropertiesBehavior.SomeModified &&
                              stateEntry.ModifiedProperties != null &&
                              stateEntry.ModifiedProperties[memberInformation.Ordinal]);
            Debug.Assert(record.GetName(ordinal) == memberInformation.Member.Name, "expect record to present properties in metadata order");
            if (memberInformation.CheckIsNotNull
                && record.IsDBNull(ordinal))
            {
                throw EntityUtil.Update(Strings.Update_NullValue(record.GetName(ordinal)), null, stateEntry);
            }
            var value = record.GetValue(ordinal);
            var entityKey = value as EntityKey;
            if (null != (object)entityKey)
            {
                return CreateEntityKeyResult(stateEntry, entityKey);
            }
            var nestedRecord = value as IExtendedDataRecord;
            if (null != nestedRecord)
            {
                var nestedModifiedPropertiesBehavior = isModified
                                                           ? ModifiedPropertiesBehavior.AllModified
                                                           : ModifiedPropertiesBehavior.NoneModified;
                var translator = m_translator;
                return ExtractResultFromRecord(
                    stateEntry, isModified, nestedRecord, useCurrentValues, translator, nestedModifiedPropertiesBehavior);
            }
            return CreateSimpleResult(stateEntry, record, memberInformation, identifier, isModified, ordinal, value);
        }
internal PropagatorResult RetrieveMember ( IEntityStateEntry stateEntry , IExtendedDataRecord record , bool useCurrentValues , EntityKey key , int ordinal , ModifiedPropertiesBehavior modifiedPropertiesBehavior ) { var memberInformation = m_memberMap [ ordinal ] ; int identifier ; if ( memberInformation . IsKeyMember ) { Debug . Assert ( null != ( object ) key , " " + " " ) ; var keyOrdinal = memberInformation . EntityKeyOrdinal . Value ; identifier = m_translator . KeyManager . GetKeyIdentifierForMemberOffset ( key , keyOrdinal , ( ( EntityType ) m_type ) . KeyMembers . Count ) ; } else if ( memberInformation . IsForeignKeyMember ) { identifier = m_translator . KeyManager . GetKeyIdentifierForMember ( key , record . GetName ( ordinal ) , useCurrentValues ) ; } else { identifier = PropagatorResult . NullIdentifier ; } var isModified = modifiedPropertiesBehavior == ModifiedPropertiesBehavior . AllModified || ( modifiedPropertiesBehavior == ModifiedPropertiesBehavior . SomeModified && stateEntry . ModifiedProperties != null && stateEntry . ModifiedProperties [ memberInformation . Ordinal ] ) ; Debug . Assert ( record . GetName ( ordinal ) == memberInformation . Member . Name , " " ) ; if ( memberInformation . CheckIsNotNull && record . IsDBNull ( ordinal ) ) { throw EntityUtil . Update ( Strings . Update_NullValue ( record . GetName ( ordinal ) ) , null , stateEntry ) ; } var value = record . GetValue ( ordinal ) ; var entityKey = value as EntityKey ; if ( null != ( object ) entityKey ) { return CreateEntityKeyResult ( stateEntry , entityKey ) ; } var nestedRecord = value as IExtendedDataRecord ; if ( null != nestedRecord ) { var nestedModifiedPropertiesBehavior = isModified ? ModifiedPropertiesBehavior . AllModified : ModifiedPropertiesBehavior . NoneModified ; var translator = m_translator ; return ExtractResultFromRecord ( stateEntry , isModified , nestedRecord , useCurrentValues , translator , nestedModifiedPropertiesBehavior ) ; } return CreateSimpleResult ( stateEntry , record , memberInformation , identifier , isModified , ordinal , value ) ; }
Requires: record must have correct type for this metadata instance.
Requires : record must have correct type for this metadata instance .
// get identifier value // retrieve identifier for this key member // determine if the member is modified // determine member value // determine what kind of member this is // entityKey (association end) // record (nested complex type) // for structural types, we track whether the entire complex type value is modified or not // simple value (column/property value)
Propagator result describing this member value.
Propagator result describing this member value .
stateEntry
IEntityStateEntry
state manager entry containing value (used for error reporting)
state manager entry containing value ( used for error reporting )
record
IExtendedDataRecord
Record containing value (used to find the actual value)
Record containing value ( used to find the actual value )
useCurrentValues
bool
Indicates whether we are reading current or original values.
Indicates whether we are reading current or original values .
key
EntityKey
Entity key for the state entry. Must be set for entity records.
Entity key for the state entry . Must be set for entity records .
ordinal
int
Ordinal of Member for which to retrieve a value.
Ordinal of Member for which to retrieve a value .
modifiedPropertiesBehavior
ModifiedPropertiesBehavior
Indicates how to determine whether a property is modified.
Indicates how to determine whether a property is modified .