コード例 #1
0
        public void Create2ObjectCircularReference()
        {
            int pA = DataUtil.CountRows("ParentA");
            int pB = DataUtil.CountRows("ParentB");
            int cA = DataUtil.CountRows("ChildA");

            ObjectTransaction transaction = manager.BeginTransaction();

            ParentBTestObject parentB = transaction.Select(typeof(ParentBTestObject), 43) as ParentBTestObject;

            ParentATestObject parentA = transaction.Create(typeof(ParentATestObject)) as ParentATestObject;

            parentA.ObjData = "A";
            parentA.ParentB = parentB;

            ChildATestObject childA = transaction.Create(typeof(ChildATestObject)) as ChildATestObject;

            childA.ParentA = parentA;
            childA.ParentB = parentB;

            transaction.Commit();

            Assert.AreEqual(pA + 1, DataUtil.CountRows("ParentA"));
            Assert.AreEqual(pB, DataUtil.CountRows("ParentB"));
            Assert.AreEqual(cA + 1, DataUtil.CountRows("ChildA"));
        }
コード例 #2
0
        public void DeleteCircularReference()
        {
            int pA = DataUtil.CountRows("ParentA");
            int pB = DataUtil.CountRows("ParentB");
            int cA = DataUtil.CountRows("ChildA");

            ObjectTransaction transaction = manager.BeginTransaction();

            ParentBTestObject parentB = transaction.Select(typeof(ParentBTestObject), 40) as ParentBTestObject;

            transaction.Delete(parentB);
            transaction.Commit();

            Assert.AreEqual(pA - 1, DataUtil.CountRows("ParentA"));
            Assert.AreEqual(pB - 1, DataUtil.CountRows("ParentB"));
            Assert.AreEqual(cA - 1, DataUtil.CountRows("ChildA"));
        }