public virtual async Task RemoveOneToManyOrphanUsingUpdateAsync()
        {
            ClearCounts();

            Contract          c  = new Contract(null, "gail", "phone");
            ContractVariation cv = new ContractVariation(c);

            cv.Text = "cv1";

            ISession     s = OpenSession();
            ITransaction t = s.BeginTransaction();

            await(s.PersistAsync(c));
            await(t.CommitAsync());
            s.Close();

            AssertInsertCount(2);
            AssertUpdateCount(0);
            ClearCounts();

            c.Variations.Remove(cv);
            cv.Contract = null;
            Assert.That(c.Variations.Count, Is.EqualTo(0));

            if (isContractVariationsBidirectional)
            {
                Assert.That(cv.Contract, Is.Null);
            }

            s = OpenSession();
            t = s.BeginTransaction();
            await(s.UpdateAsync(c));
            await(t.CommitAsync());
            s.Close();

            AssertUpdateCount(isContractVersioned ? 1 : 0);
            AssertDeleteCount(1);
            ClearCounts();

            s = OpenSession();
            t = s.BeginTransaction();
            c = await(s.CreateCriteria <Contract>().UniqueResultAsync <Contract>());
            Assert.That(c.Variations.Count, Is.EqualTo(0));
            cv = await(s.CreateCriteria <ContractVariation>().UniqueResultAsync <ContractVariation>());
            Assert.That(cv, Is.Null);
            await(s.DeleteAsync(c));
            Assert.That(await(s.CreateCriteria <Contract>().SetProjection(Projections.RowCountInt64()).UniqueResultAsync <long>()), Is.EqualTo(0L));
            Assert.That(await(s.CreateCriteria <ContractVariation>().SetProjection(Projections.RowCountInt64()).UniqueResultAsync <long>()), Is.EqualTo(0L));
            await(t.CommitAsync());
            s.Close();

            AssertUpdateCount(0);
            AssertDeleteCount(1);
        }
        public virtual void RemoveOneToManyOrphanUsingMerge()
        {
            Contract          c  = new Contract(null, "gail", "phone");
            ContractVariation cv = new ContractVariation(c);

            ISession     s = OpenSession();
            ITransaction t = s.BeginTransaction();

            s.Persist(c);
            t.Commit();
            s.Close();

            AssertInsertCount(2);
            AssertUpdateCount(0);
            ClearCounts();

            c.Variations.Remove(cv);
            cv.Contract = null;
            Assert.That(c.Variations.Count, Is.EqualTo(0));
            if (isContractVariationsBidirectional)
            {
                Assert.That(cv.Contract, Is.Null);
            }

            s  = OpenSession();
            t  = s.BeginTransaction();
            c  = (Contract)s.Merge(c);
            cv = (ContractVariation)s.Merge(cv);
            t.Commit();
            s.Close();

            AssertUpdateCount(isContractVersioned ? 1 : 0);
            AssertDeleteCount(1);
            ClearCounts();

            s = OpenSession();
            t = s.BeginTransaction();
            c = s.CreateCriteria <Contract>().UniqueResult <Contract>();
            Assert.That(c.Variations.Count, Is.EqualTo(0));
            cv = s.CreateCriteria <ContractVariation>().UniqueResult <ContractVariation>();
            Assert.That(cv, Is.Null);
            s.Delete(c);
            Assert.That(s.CreateCriteria <Contract>().SetProjection(Projections.RowCountInt64()).UniqueResult <long>(), Is.EqualTo(0L));
            Assert.That(s.CreateCriteria <ContractVariation>().SetProjection(Projections.RowCountInt64()).UniqueResult <long>(), Is.EqualTo(0L));
            t.Commit();
            s.Close();

            AssertUpdateCount(0);
            AssertDeleteCount(1);
        }
		public virtual void RemoveOneToManyOrphanUsingUpdate()
		{
			ClearCounts();
	
			Contract c = new Contract(null, "gail", "phone");
			ContractVariation cv = new ContractVariation(c);
			cv.Text = "cv1";
	
			ISession s = OpenSession();
			ITransaction t = s.BeginTransaction();
			s.Persist(c);
			t.Commit();
			s.Close();
	
			AssertInsertCount(2);
			AssertUpdateCount(0);
			ClearCounts();
	
			c.Variations.Remove(cv);
			cv.Contract = null;
			Assert.That(c.Variations.Count, Is.EqualTo(0));
			
			if (isContractVariationsBidirectional)
			{
				Assert.That(cv.Contract, Is.Null);
			}
	
			s = OpenSession();
			t = s.BeginTransaction();
			s.Update(c);
			t.Commit();
			s.Close();
	
			AssertUpdateCount(isContractVersioned ? 1 : 0);
			AssertDeleteCount(1);
			ClearCounts();
	
			s = OpenSession();
			t = s.BeginTransaction();
			c = s.CreateCriteria<Contract>().UniqueResult<Contract>();
			Assert.That(c.Variations.Count, Is.EqualTo(0));
			cv = s.CreateCriteria<ContractVariation>().UniqueResult<ContractVariation>();
			Assert.That(cv, Is.Null);
			s.Delete(c);
			Assert.That(s.CreateCriteria<Contract>().SetProjection(Projections.RowCountInt64()).UniqueResult<long>(), Is.EqualTo(0L));
			Assert.That(s.CreateCriteria<ContractVariation>().SetProjection(Projections.RowCountInt64()).UniqueResult<long>(), Is.EqualTo(0L));
			t.Commit();
			s.Close();
	
			AssertUpdateCount(0);
			AssertDeleteCount(1);
		}