public void TestInsertUserClassMutiRollback() { var db = new NLORMMSSQLDb(ConnectionString); db.CreateTable <TestClassUser>(); var trans = db.BeginTransaction(); var insertList = new List <TestClassUser>(); for (int i = 0; i < 30; i++) { var testObj = new TestClassUser { ID = i, Name = "Name " + i, CreateTime = DateTime.Now.AddDays(i) }; insertList.Add(testObj); } foreach (TestClassUser user in insertList) { db.Insert <TestClassUser>(user); } trans.Rollback(); db.Close(); db = new NLORMMSSQLDb(ConnectionString); var selLis = db.Query <TestClassUser>(); Assert.AreEqual(selLis.Count(), 0); }
public void TestTransactionCommit() { var db = new NLORMMSSQLDb(ConnectionString); db.CreateTable <TestClassUser>(); var trans = db.BeginTransaction(); var testObj = new TestClassUser(); testObj.ID = 1; testObj.Name = "Name " + 1; testObj.CreateTime = DateTime.Now; db.Insert <TestClassUser>(testObj); trans.Commit(); db.Close(); db = new NLORMMSSQLDb(ConnectionString); var selLis = db.Query <TestClassUser>(); Assert.AreEqual(selLis.Count(), 1); }