Пример #1
0
        /// <summary>
        /// 提交
        /// </summary>
        /// <param name="dbName"></param>
        public static void Commit(string dbName)
        {
            CheckDbName(dbName);

            string key = GetKey(dbName);

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

            DataAccessContext dac = ServiceContext.Current[key] as DataAccessContext;

            if (dac == null)
            {
                throw new Exception("DataAccessContext is null");
            }

            try
            {
                dac.Commit();
            }
            finally
            {
                dac.CloseConnection();

                ServiceContext.Current.Remove(key);
            }
        }