Ejemplo n.º 1
0
        public void TestContext(string context)
        {
            var ctx = new DataContext(context);

            ctx.GetTable<Person>().ToList();

            ctx.KeepConnectionAlive = true;

            ctx.GetTable<Person>().ToList();
            ctx.GetTable<Person>().ToList();

            ctx.KeepConnectionAlive = false;

            using (var tran = new DataContextTransaction(ctx))
            {
                ctx.GetTable<Person>().ToList();

                tran.BeginTransaction();

                ctx.GetTable<Person>().ToList();
                ctx.GetTable<Person>().ToList();

                tran.CommitTransaction();
            }
        }
Ejemplo n.º 2
0
        public void TestContext([IncludeDataContexts(ProviderName.SqlServer2008)] string context)
        {
            var ctx = new DataContext(context);

            ctx.GetTable<Person>().ToList();

            ctx.KeepConnectionAlive = true;

            ctx.GetTable<Person>().ToList();
            ctx.GetTable<Person>().ToList();

            ctx.KeepConnectionAlive = false;

            using (var tran = new DataContextTransaction(ctx))
            {
                ctx.GetTable<Person>().ToList();

                tran.BeginTransaction();

                ctx.GetTable<Person>().ToList();
                ctx.GetTable<Person>().ToList();

                tran.CommitTransaction();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Starts new transaction for current context with default isolation level.
        /// If connection already has transaction, it will be rolled back.
        /// </summary>
        /// <param name="autoCommitOnDispose">Not supported, see <a href="https://github.com/linq2db/linq2db/issues/104">issue</a>.</param>
        /// <returns>Database transaction object.</returns>
        public virtual DataContextTransaction BeginTransaction(bool autoCommitOnDispose = true)
        {
            var dct = new DataContextTransaction(this);

            dct.BeginTransaction();

            return(dct);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Starts new transaction for current context with specified isolation level.
        /// If connection already has transaction, it will be rolled back.
        /// </summary>
        /// <param name="level">Transaction isolation level.</param>
        /// <returns>Database transaction object.</returns>
        public virtual DataContextTransaction BeginTransaction(IsolationLevel level)
        {
            var dct = new DataContextTransaction(this);

            dct.BeginTransaction(level);

            return(dct);
        }
Ejemplo n.º 5
0
        public virtual DataContextTransaction BeginTransaction(bool autoCommitOnDispose = true)
        {
            var dct = new DataContextTransaction(this);

            dct.BeginTransaction();

            return dct;
        }
Ejemplo n.º 6
0
        public virtual DataContextTransaction BeginTransaction(IsolationLevel level)
        {
            var dct = new DataContextTransaction(this);

            dct.BeginTransaction(level);

            return dct;
        }