score:4

Accepted answer

I think that the problem is that you are storing IQueryable's in your cache, and then cachednews contains an IQueryable that hits the database.

Try the following changes.

public IQueryable<VictoryList> GetVictoryList() {
            // ...
            if (cachednews == null)
            {

                var results = from // ...
                results = results.ToList().AsQueryable(); // force query execution

                SqlCacheDependency dependency = // ...;
                HttpContext.Current.Cache.Add(cacheKey, 
                    results, // now just the result are stored
                    dependency, 
                    DateTime.MaxValue,
                    TimeSpan.Zero, 
                    CacheItemPriority.Normal, 
                    null); 

                return results;
            }
            return cachednews;
}

More questions

More questions with similar tag