public void ShouldNotSaveRemoveChild() { var parent = new UniParent(); parent.Children.Add(new UniChild()); using (var s = OpenSession()) { using (var tx = s.BeginTransaction()) { id = (Guid) s.Save(parent); parent.Children.Clear(); parent.Children.Add(new UniChild()); tx.Commit(); } } using (var s = OpenSession()) { using (s.BeginTransaction()) { Assert.That(s.Get<UniParent>(id).Children.Count, Is.EqualTo(1)); Assert.That(s.CreateCriteria<UniChild>().List().Count, Is.EqualTo(1)); } } }
public void ShouldNotSaveRemoveChild() { var parent = new UniParent(); parent.Children.Add(new UniChild()); using (var s = OpenSession()) { using (var tx = s.BeginTransaction()) { id = (Guid)s.Save(parent); parent.Children.Clear(); parent.Children.Add(new UniChild()); tx.Commit(); } } using (var s = OpenSession()) { using (s.BeginTransaction()) { Assert.That(s.Get <UniParent>(id).Children.Count, Is.EqualTo(1)); Assert.That(s.CreateCriteria <UniChild>().List().Count, Is.EqualTo(1)); } } }
public async Task ShouldNotSaveRemoveChildAsync() { var parent = new UniParent(); parent.Children.Add(new UniChild()); using (var s = OpenSession()) { using (var tx = s.BeginTransaction()) { id = (Guid)await(s.SaveAsync(parent)); parent.Children.Clear(); parent.Children.Add(new UniChild()); await(tx.CommitAsync()); } } using (var s = OpenSession()) { using (s.BeginTransaction()) { Assert.That((await(s.GetAsync <UniParent>(id))).Children.Count, Is.EqualTo(1)); Assert.That((await(s.CreateCriteria <UniChild>().ListAsync())).Count, Is.EqualTo(1)); } } }