/// <summary>
        /// 构造一个本地事务代码块
        /// </summary>
        /// <param name="dbSetting">数据库配置</param>
        /// <param name="level">
        /// 此级别只在最外层的代码块中有效。
        /// </param>
        public LocalTransactionBlock_1_0(DbSetting dbSetting, IsolationLevel level)
        {
            this._dbSetting = dbSetting;
            this._level = level;

            var tranRef = GetTransactionRef(this._dbSetting.Database, this);

            tranRef.RefCount++;

            this._currentRef = tranRef;
        }
 /// <summary>
 /// 清除当前数据库在当前线程中正在使用的事务。
 /// </summary>
 private void ClearTransactionRef()
 {
     var name = LocalContextName(this._dbSetting.Database);
     ServerContext.Items.Remove(name);
     this._currentRef = null;
 }
        /// <summary>
        /// 获取某个数据库在当前线程中正在被使用的事务引用。
        /// </summary>
        /// <param name="database"></param>
        /// <param name="currentBlock">如果指定此对象,则在还没有创建事务时,使用此类的抽象方法创建一个新的事务对象。</param>
        /// <returns></returns>
        private static TransactionRef GetTransactionRef(string database, LocalTransactionBlock_1_0 currentBlock)
        {
            var name = LocalContextName(database);
            var items = ServerContext.Items;

            object value = null;
            items.TryGetValue(name, out value);

            var tranRef = value as TransactionRef;
            if (tranRef == null && currentBlock != null)
            {
                var tran = currentBlock.BeginTransaction();

                tranRef = new TransactionRef(tran);
                items.Add(name, tranRef);
            }

            return tranRef;
        }