Closed as duplicate of#2028
Closed as duplicate of#2028
Description
A child entity that was temporarily added and then deleted will still be inserted if the parent entity is reattached to a new session.
Book book = null;
using (var s = OpenSession())
using (var tr = s.BeginTransaction())
{
book = new Book { Id = 1};
book.Words = new List<Word> { new Word { Id = 1, Parent = book } };
s.Save(book);
tr.Commit();
}
// Adding temporary child on detached entity.
Word word = new Word { Id = 2, Parent = book };
book.Words.Add(word);
using (var s = OpenSession())
using (var tr = s.BeginTransaction())
{
// Attach entity to new session and remove temporary child.
s.Update(book);
book.Words.Remove(word);
// This produces insert command for removed child.
tr.Commit();
}
Maybe it's a duplicate of #2028
Tests here:
#3666
Metadata
Metadata
Assignees
Labels
No labels