コード例 #1
0
        private TResult ExecuteSqlRequest()
        {
            TResult commandResult;

            using (SqlConnection sqlConnection = new SqlConnection(this.ConnectionString))
            {
                using (SqlCommand sqlCommand = sqlConnection.CreateCommand())
                {
                    sqlConnection.Open();
                    this.CommandBody(sqlCommand);
                    sqlConnection.Close();
                    commandResult = this.GetCommandResult(sqlCommand);
                    if (commandResult != null)
                    {
                        this.CacheDependency   = CacheDependencyResolver.GetCachedDataDependencies(base.StoredProcedureName);
                        this.CacheItemPriority = CacheDependencyResolver.GetCacheItemPriority(base.StoredProcedureName);
                        if (this.CacheDependency == null)
                        {
                            Logger.WarnFormat(LogMessages.SqlDacs.SqlCommands.CacheDependencyNotFound, new object[] { base.StoredProcedureName });
                        }
                        else
                        {
                            MlcSlcCache.InsertItemInCache <TResult>(this.CacheKey, commandResult, this.CacheDependency, this.SlidingExpiration, this.CacheItemPriority);
                            return(commandResult);
                        }
                    }
                }
            }
            return(commandResult);
        }
コード例 #2
0
 public override void Execute()
 {
     if (!ConfigurationManager.Instance.IsEnabledDbCache)
     {
         base.Execute();
         return;
     }
     try
     {
         IEnumerable <string> freeCacheDependencies = CacheDependencyResolver.GetFreeCacheDependencies(base.StoredProcedureName);
         if (freeCacheDependencies == null)
         {
             Logger.WarnFormat(LogMessages.SqlDacs.SqlCommands.FreeCacheDependencyNotFound, new object[] { base.StoredProcedureName });
         }
         else
         {
             this.CacheKeyPrefixes = freeCacheDependencies.Select <string, string>(new Func <string, string>(MlcSlcCache.GetCacheKeyPrefix)).ToArray <string>();
             MlcSlcCache.RemoveItemsFromCache(this.CacheKeyPrefixes);
         }
         using (SqlConnection sqlConnection = new SqlConnection(this.ConnectionString))
         {
             using (SqlCommand sqlCommand = sqlConnection.CreateCommand())
             {
                 sqlConnection.Open();
                 this.CommandBody(sqlCommand);
                 sqlConnection.Close();
             }
         }
     }
     catch (Exception exception)
     {
         Logger.Error(LogMessages.SqlDacs.SqlCommands.CommandExecutionError, exception);
         throw;
     }
 }
コード例 #3
0
ファイル: DependencyResolver.cs プロジェクト: rrsc/AngleSharp
        public void InnerSetResolver(IDependencyResolver resolver)
        {
            if (resolver == null)
                throw new ArgumentNullException("resolver");

            _current = resolver;
            _currentCache = new CacheDependencyResolver(_current);
        }
コード例 #4
0
 public void InnerSetResolver(IDependencyResolver resolver)
 {
     if (resolver == null)
     {
         throw new ArgumentNullException("resolver");
     }
     _current      = resolver;
     _currentCache = new CacheDependencyResolver(_current);
 }