src/Shared/EntityFramework/Core/Mapping/Update/Internal/KeyManager.cs
// <summary>
// Ensures firstId and secondId belong to the same partition
// </summary>
Ensures firstId and secondId belong to the same partition
Ensures firstId and secondId belong to the same partition
internal void AssociateNodes(int firstId, int secondId)
        {
            if (firstId == secondId)
            {
                return;
            }
            var firstPartition = _identifiers[firstId].Partition;
            if (null != firstPartition)
            {
                var secondPartition = _identifiers[secondId].Partition;
                if (null != secondPartition)
                {
                    firstPartition.Merge(this, secondPartition);
                }
                else
                {
                    firstPartition.AddNode(this, secondId);
                }
            }
            else
            {
                var secondPartition = _identifiers[secondId].Partition;
                if (null != secondPartition)
                {
                    secondPartition.AddNode(this, firstId);
                }
                else
                {
                    Partition.CreatePartition(this, firstId, secondId);
                }
            }
        }
internal void AssociateNodes ( int firstId , int secondId ) { if ( firstId == secondId ) { return ; } var firstPartition = _identifiers [ firstId ] . Partition ; if ( null != firstPartition ) { var secondPartition = _identifiers [ secondId ] . Partition ; if ( null != secondPartition ) { firstPartition . Merge ( this , secondPartition ) ; } else { firstPartition . AddNode ( this , secondId ) ; } } else { var secondPartition = _identifiers [ secondId ] . Partition ; if ( null != secondPartition ) { secondPartition . AddNode ( this , firstId ) ; } else { Partition . CreatePartition ( this , firstId , secondId ) ; } } }
Ensures firstId and secondId belong to the same partition
Ensures firstId and secondId belong to the same partition
// A node is (trivially) associated with itself // merge partitions // add y to existing x partition // add x to existing y partition // Neither node is known
firstId
int
secondId
int