Esempio n. 1
0
        public void 交易()
        {
            using (var db = new LabEmployee2DB(ConnectionName))
            {
                db.BeginTransaction();
                var count = 0;
                try
                {
                    var employee = new Employee {
                        Id = Guid.NewGuid(), Name = "小章", Age = 18
                    };
                    var identity = new Identity {
                        EmployeeId = employee.Id, Account = "yao", Password = "******"
                    };
                    count += db.Insert(employee);
                    count += db.Insert(identity);
                    db.CommitTransaction();
                }
                catch (Exception e)
                {
                    db.RollbackTransaction();
                }

                Assert.IsTrue(count == 2);
            }
        }