Exemplo n.º 1
0
        public void InsertViaTransactionCommit()
        {
            int rowCount = _indepDalc.GetRowCount();

            using (var dalc = new SqlCeDalc(_connstr)) {
                using (var trans = dalc.BeginTransaction()) {
                    dalc.InsertOneRow("a row");

                    int newRowCount = dalc.GetRowCount();
                    Assert.AreEqual(rowCount + 1, newRowCount);
                    trans.Commit();
                }
            }
            // Ensure row was indeed committed
            Assert.AreEqual(rowCount + 1, _indepDalc.GetRowCount());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Inserts two rows into test_table. 
        /// 
        /// If commit, then commits transaction (expected rowcount == rowcount +2),
        /// else rolls back (expected rowcount == rowcount)
        /// </summary>
        /// <param name="commit"></param>
        private void DoSharedTransactionWork(bool commit)
        {
            using (var dalc = new SqlCeDalc(_connstr)) {
                using (var trans = dalc.BeginTransaction()) {
                    // Do some work in the outer dalc
                    dalc.InsertOneRow("outer");

                    using (var innerDalc = new SqlCeDalc(trans)) {
                        innerDalc.InsertOneRow("inner");
                    }

                    if (commit) {
                        trans.Commit();
                    } else {
                        trans.Rollback();
                    }
                }
            }
        }