Exemple #1
0
        public void Test4()
        {
            dynamic neworg = OrmUtils.Model("Org").NewObject();

            neworg.Code = "Trans_Org";
            neworg.Name = "事务测试-机构01";

            dynamic newuser = OrmUtils.Model("User").NewObject();

            newuser.Name = "事务测试-用户01";

            int trans = OrmUtils.GetTransaction();

            try
            {
                OrmUtils.Model("Org").SetValues(neworg).Save(trans);
                OrmUtils.Model("User").SetValues(newuser).Save(trans);
                OrmUtils.CommitTransaction(trans);
            }
            catch
            {
                OrmUtils.RollbackTransaction(trans);
            }

            List <dynamic> result = OrmUtils.Model("Org").Equals("Name", "事务测试-机构01").Query();

            Assert.AreEqual <int>(result.Count, 1);

            List <dynamic> result2 = OrmUtils.Model("User").Equals("Name", "事务测试-用户01").Query();

            Assert.AreEqual <int>(result2.Count, 1);
        }