src/Shared/EntityFramework/Core/Mapping/Update/Internal/Propagator.JoinPropagator.SubstitutingCloneVisitor.cs
// <summary>
// Construct a new placeholder with the shape of the given placeholder. Key values are
// injected into the resulting place holder and default values are substituted with
// either propagator constants or progagator nulls depending on the mode established
// by the <paramref name="mode" /> flag.
// </summary>
// <remarks>
// The key is essentially an array of values. The key map indicates that for a particular
// placeholder an expression (keyMap.Keys) corresponds to some ordinal in the key array.
// </remarks>
// <param name="placeholder"> Placeholder to clone </param>
// <param name="key"> Key to substitute </param>
// <param name="placeholderKey"> Key elements in the placeholder (ordinally aligned with 'key') </param>
// <param name="mode"> Mode of operation. </param>
// <returns> Cloned placeholder with key values </returns>
Construct a new placeholder with the shape of the given placeholder. Key values are
injected into the resulting place holder and default values are substituted with
either propagator constants or progagator nulls depending on the mode established
by the  flag.
Construct a new placeholder with the shape of the given placeholder . Key values are injected into the resulting place holder and default values are substituted with either propagator constants or progagator nulls depending on the mode established by the flag .
internal static PropagatorResult Populate(
                    PropagatorResult placeholder, CompositeKey key,
                    CompositeKey placeholderKey, PopulateMode mode)
                {
                    DebugCheck.NotNull(placeholder);
                    DebugCheck.NotNull(key);
                    DebugCheck.NotNull(placeholderKey);
                    var isNull = mode == PopulateMode.NullModified || mode == PopulateMode.NullPreserve;
                    var preserve = mode == PopulateMode.NullPreserve || mode == PopulateMode.Unknown;
                    var flags = PropagatorFlags.NoFlags;
                    if (!isNull)
                    {
                        flags |= PropagatorFlags.Unknown;
                    } 
                    if (preserve)
                    {
                        flags |= PropagatorFlags.Preserve;
                    }
                    var result = placeholder.Replace(
                        node =>
                            {
                                var keyIndex = -1;
                                for (var i = 0; i < placeholderKey.KeyComponents.Length; i++)
                                {
                                    if (placeholderKey.KeyComponents[i] == node)
                                    {
                                        keyIndex = i;
                                        break;
                                    }
                                }
                                if (keyIndex != -1)
                                {
                                    return key.KeyComponents[keyIndex];
                                }
                                else
                                {
                                    var value = isNull ? null : node.GetSimpleValue();
                                    return PropagatorResult.CreateSimpleValue(flags, value);
                                }
                            });
                    return result;
                }
internal static PropagatorResult Populate ( PropagatorResult placeholder , CompositeKey key , CompositeKey placeholderKey , PopulateMode mode ) { DebugCheck . NotNull ( placeholder ) ; DebugCheck . NotNull ( key ) ; DebugCheck . NotNull ( placeholderKey ) ; var isNull = mode == PopulateMode . NullModified || mode == PopulateMode . NullPreserve ; var preserve = mode == PopulateMode . NullPreserve || mode == PopulateMode . Unknown ; var flags = PropagatorFlags . NoFlags ; if ( ! isNull ) { flags |= PropagatorFlags . Unknown ; } if ( preserve ) { flags |= PropagatorFlags . Preserve ; } var result = placeholder . Replace ( node => { var keyIndex = - 1 ; for ( var i = 0 ; i < placeholderKey . KeyComponents . Length ; i ++ ) { if ( placeholderKey . KeyComponents [ i ] == node ) { keyIndex = i ; break ; } } if ( keyIndex != - 1 ) { return key . KeyComponents [ keyIndex ] ; } else { var value = isNull ? null : node . GetSimpleValue ( ) ; return PropagatorResult . CreateSimpleValue ( flags , value ) ; } } ) ; return result ; }
Construct a new placeholder with the shape of the given placeholder.
Construct a new placeholder with the shape of the given placeholder .
// Figure out which flags to apply to generated elements. // only null values are known // See if this is a key element // Key value. // for simple entries, just return using the markup context for this // populator
Cloned placeholder with key values
Cloned placeholder with key values
placeholder
PropagatorResult
Placeholder to clone
Placeholder to clone
key
CompositeKey
Key to substitute
Key to substitute
placeholderKey
CompositeKey
Key elements in the placeholder (ordinally aligned with 'key')
Key elements in the placeholder ( ordinally aligned with ' key ' )
mode
PopulateMode
Mode of operation.
Mode of operation .
remarks
The key is essentially an array of values. The key map indicates that for a particular
placeholder an expression (keyMap.Keys) corresponds to some ordinal in the key array.
The key is essentially an array of values . The key map indicates that for a particular placeholder an expression ( keyMap . Keys ) corresponds to some ordinal in the key array .