public void InsertUsingSystemTransactions() { var options = new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted }; SqliteSession.Trace = true; using (var db = new SqliteSession("Data Source=TempDb" + DateTime.Now.Ticks + ".db;DefaultTimeout=100", false)) { db.Connection.Open(); db.CreateTable<TestObj>(); db.Connection.Close(); using (var trans = new TransactionScope(TransactionScopeOption.Required, options)) { db.Connection.Open(); db.Insert(new TestObj { Text = "My Text" }); } Assert.AreEqual(0, db.Table<TestObj>().Count()); db.Connection.Close(); using (var trans = new TransactionScope(TransactionScopeOption.Required, options)) { db.Connection.Open(); db.Insert(new TestObj { Text = "My Text" }); trans.Complete(); } Assert.AreEqual(1, db.Table<TestObj>().Count()); } }
public void InsertUsingSystemTransactions() { var options = new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted }; #if NETFX_CORE var tempFileName = Windows.Storage.ApplicationData.Current.TemporaryFolder.Path + "\\TempDb" + DateTime.Now.Ticks + ".db"; #else var tempFileName = Path.GetTempFileName(); #endif SqliteSession.Trace = true; using (var db = new SqliteSession("Data Source=" + tempFileName + ";DefaultTimeout=100", false)) { db.Connection.Open(); db.CreateTable <TestObj>(); db.Connection.Close(); using (var trans = new TransactionScope(TransactionScopeOption.Required, options)) { db.Connection.Open(); db.Insert(new TestObj { Text = "My Text" }); } Assert.AreEqual(0, db.Table <TestObj>().Count()); db.Connection.Close(); using (var trans = new TransactionScope(TransactionScopeOption.Required, options)) { db.Connection.Open(); db.Insert(new TestObj { Text = "My Text" }); trans.Complete(); } Assert.AreEqual(1, db.Table <TestObj>().Count()); } }
public void InsertUsingSystemTransactions() { var options = new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted }; SqliteSession.Trace = true; using (var db = new SqliteSession("Data Source=TempDb" + DateTime.Now.Ticks + ".db;DefaultTimeout=100", false)) { db.Connection.Open(); db.CreateTable <TestObj>(); db.Connection.Close(); using (var trans = new TransactionScope(TransactionScopeOption.Required, options)) { db.Connection.Open(); db.Insert(new TestObj { Text = "My Text" }); } Assert.AreEqual(0, db.Table <TestObj>().Count()); db.Connection.Close(); using (var trans = new TransactionScope(TransactionScopeOption.Required, options)) { db.Connection.Open(); db.Insert(new TestObj { Text = "My Text" }); trans.Complete(); } Assert.AreEqual(1, db.Table <TestObj>().Count()); } }
public void InsertUsingSystemTransactions() { var options = new TransactionOptions {IsolationLevel = IsolationLevel.ReadCommitted}; #if NETFX_CORE var tempFileName = Windows.Storage.ApplicationData.Current.TemporaryFolder.Path + "\\TempDb" + DateTime.Now.Ticks + ".db"; #else var tempFileName = Path.GetTempFileName(); #endif SqliteSession.Trace = true; using (var db = new SqliteSession("Data Source=" + tempFileName + ";DefaultTimeout=100", false)) { db.Connection.Open(); db.CreateTable<TestObj>(); db.Connection.Close(); using (var trans = new TransactionScope(TransactionScopeOption.Required, options)) { db.Connection.Open(); db.Insert(new TestObj { Text = "My Text" }); } Assert.AreEqual(0, db.Table<TestObj>().Count()); db.Connection.Close(); using (var trans = new TransactionScope(TransactionScopeOption.Required, options)) { db.Connection.Open(); db.Insert(new TestObj { Text = "My Text" }); trans.Complete(); } Assert.AreEqual(1, db.Table<TestObj>().Count()); } }