示例#1
0
        /// <summary>
        /// 事物
        /// </summary>
        /// <param name="dbName"></param>
        public static void BeginTransaction(string dbName)
        {
            CheckDbName(dbName);

            string key = GetKey(dbName);

            if (ServiceContext.Current.Contains(key))
            {
                throw new InvalidOperationException(string.Format("数据库{0}的上下文环境已经存在。", dbName));
            }
            DataAccessContext dac = new DataAccessContext(GetDatabase(dbName));

            ServiceContext.Current.Add(key, dac);
            dac.BeginTransaction();
        }