Пример #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();
            }
        }
Пример #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();
            }
        }
Пример #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);
        }
Пример #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);
        }
Пример #5
0
        public virtual DataContextTransaction BeginTransaction(bool autoCommitOnDispose = true)
        {
            var dct = new DataContextTransaction(this);

            dct.BeginTransaction();

            return dct;
        }
Пример #6
0
        public virtual DataContextTransaction BeginTransaction(IsolationLevel level)
        {
            var dct = new DataContextTransaction(this);

            dct.BeginTransaction(level);

            return dct;
        }