Skip to content

Commit

Permalink
Fixed issues with identifying child items correctly after parent refe…
Browse files Browse the repository at this point in the history
…rence re-associated.
  • Loading branch information
gmcelhanon committed Nov 10, 2024
1 parent 58aad09 commit ee0de90
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,19 @@ public void Reattach(object parent, string collectionPropertyName)
// Only process if we haven't already
if (Owner == null)
{
// Clear the wrapped set after copying to a list
var items = new List<T>(WrappedSet);
WrappedSet.Clear();

// Set the parent references on the items, and re-add to the set
// (so GetHashCodes used in the underlying HashSet are correct for persistence operations)
foreach (T item in items)
{
(item as IChildEntity)!.SetParent(parent);
WrappedSet.Add(item);
}

// Finalize addition of collection back into the current Session
var persisters = GetPersisters(parent, collectionPropertyName);

var id = persisters.EntityPersister.GetIdentifier(parent);
Expand Down

0 comments on commit ee0de90

Please sign in to comment.