public void PersistOutsideTransactionCascadedToInverseCollection()
        {
            long initialInsertCount = Sfi.Statistics.EntityInsertCount;

            using (var s = OpenSession())
            {
                MyEntity myEntity2 = new MyEntity("test-persist-2");
                MyChild  child     = new MyChild("test-child-persist-inverse");
                myEntity2.InverseChildren.Add(child);
                child.InverseParent = myEntity2;
                s.Persist(myEntity2);
                Assert.AreEqual(
                    initialInsertCount,
                    Sfi.Statistics.EntityInsertCount,
                    "persist on identity column not delayed");
                Assert.AreEqual(0, myEntity2.Id);
                s.Flush();
                Assert.AreEqual(
                    initialInsertCount + 2,
                    Sfi.Statistics.EntityInsertCount,
                    "delayed persist insert not executed on flush");
                s.Close();
            }

            using (var s = OpenSession())
                using (var t = s.BeginTransaction())
                {
                    s.Delete("from MyChild");
                    s.Delete("from MyEntity");
                    t.Commit();
                    s.Close();
                }
        }
Пример #2
0
        public async Task PersistOutsideTransactionCascadedToInverseCollectionAsync()
        {
            long     initialInsertCount = Sfi.Statistics.EntityInsertCount;
            ISession s         = OpenSession();
            MyEntity myEntity2 = new MyEntity("test-persist-2");
            MyChild  child     = new MyChild("test-child-persist-inverse");

            myEntity2.InverseChildren.Add(child);
            child.InverseParent = myEntity2;
            await(s.PersistAsync(myEntity2));
            Assert.AreEqual(initialInsertCount, Sfi.Statistics.EntityInsertCount, "persist on identity column not delayed");
            Assert.AreEqual(0, myEntity2.Id);
            await(s.FlushAsync());
            Assert.AreEqual(initialInsertCount + 2, Sfi.Statistics.EntityInsertCount, "delayed persist insert not executed on flush");
            s.Close();

            s = OpenSession();
            s.BeginTransaction();
            await(s.DeleteAsync("from MyChild"));
            await(s.DeleteAsync("from MyEntity"));
            await(s.Transaction.CommitAsync());
            s.Close();
        }
		public void PersistOutsideTransactionCascadedToInverseCollection()
		{
			long initialInsertCount = Sfi.Statistics.EntityInsertCount;
			ISession s = OpenSession();
			MyEntity myEntity2 = new MyEntity("test-persist-2");
			MyChild child = new MyChild("test-child-persist-inverse");
			myEntity2.InverseChildren.Add(child);
			child.InverseParent= myEntity2;
			s.Persist(myEntity2);
			Assert.AreEqual(initialInsertCount, Sfi.Statistics.EntityInsertCount,"persist on identity column not delayed");
			Assert.AreEqual(0, myEntity2.Id);
			s.Flush();
			Assert.AreEqual(initialInsertCount + 2, Sfi.Statistics.EntityInsertCount,"delayed persist insert not executed on flush");
			s.Close();

			s = OpenSession();
			s.BeginTransaction();
			s.Delete("from MyChild");
			s.Delete("from MyEntity");
			s.Transaction.Commit();
			s.Close();
		}