示例#1
0
		public void ShouldNotSaveRemoveChild()
		{
			var parent = new BiParent();
			parent.AddChild(new BiChild());
			using (var s = OpenSession())
			{
				using (var tx = s.BeginTransaction())
				{
					id = (Guid)s.Save(parent);
					parent.Children.Clear();
					parent.AddChild(new BiChild());
					tx.Commit();
				}
			}
			using (var s = OpenSession())
			{
				using (s.BeginTransaction())
				{
					Assert.That(s.Get<BiParent>(id).Children.Count, Is.EqualTo(1));
					Assert.That(s.CreateCriteria<BiChild>().List().Count, Is.EqualTo(1));
				}
			}
		}
示例#2
0
        public async Task ShouldNotSaveRemoveChildAsync()
        {
            var parent = new BiParent();

            parent.AddChild(new BiChild());
            using (var s = OpenSession())
            {
                using (var tx = s.BeginTransaction())
                {
                    id = (Guid)await(s.SaveAsync(parent));
                    parent.Children.Clear();
                    parent.AddChild(new BiChild());
                    await(tx.CommitAsync());
                }
            }
            using (var s = OpenSession())
            {
                using (s.BeginTransaction())
                {
                    Assert.That((await(s.GetAsync <BiParent>(id))).Children.Count, Is.EqualTo(1));
                    Assert.That((await(s.CreateCriteria <BiChild>().ListAsync())).Count, Is.EqualTo(1));
                }
            }
        }
示例#3
0
        public void ShouldNotSaveRemoveChild()
        {
            var parent = new BiParent();

            parent.AddChild(new BiChild());
            using (var s = OpenSession())
            {
                using (var tx = s.BeginTransaction())
                {
                    id = (Guid)s.Save(parent);
                    parent.Children.Clear();
                    parent.AddChild(new BiChild());
                    tx.Commit();
                }
            }
            using (var s = OpenSession())
            {
                using (s.BeginTransaction())
                {
                    Assert.That(s.Get <BiParent>(id).Children.Count, Is.EqualTo(1));
                    Assert.That(s.CreateCriteria <BiChild>().List().Count, Is.EqualTo(1));
                }
            }
        }