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
- Should I still see the query hit in SQL Profiler?
- How do I "test" a sql query that modifies data, i.e. see the output before committing in sql server 2008?
- SQL query for displaying count if same name comes in adjacent row it should show the count else 1
- A not-existing column should not break the sql query within select
- Should I make my SQL query asynchronous in the following case instance?
- How to save SQL query analytics in the background while still delivering records to user?
- Should I put my logic in the underlying SQL query or in the SSRS report?
- Where should i put my C# if statement, for the case my sql query comes back blank?
- SQL How to return one ID in a select distinct query with multiple IDs in a table while still returning all other IDs as well (not just the top row)
- how to see the Table structure in the Query Analyzer MS SQL Server
- Should I cache SQL database data and query it locally? Or have the app query the database directly?
- Does the query from the linked server still continue even though you have obtained your result in your SQL Server?
- Is there a query to see all the references in a SQL Server table?
- SQL - How can I get the quantity of parts from this query and still have all the notes associated with these requests?
- How to loop data from a table in sql server and using the returned data to query another table. Please see
- What should be the query for setting foreign key to zero in sql server r2?
- What changes should be done to sql query to get the mentioned ouput?
- Better way to construct an SQL query with multiple wheres which hit the same column
- Should you choose the MONEY or DECIMAL(x,y) datatypes in SQL Server?
- How can I clear the SQL Server query cache?
- How to see query history in SQL Server Management Studio
- SQL Server reports 'Invalid column name', but the column is present and the query works through management studio
- Can't see the triggers that I created in SQL Server Management Studio 2008
- Comparing two bitmasks in SQL to see if any of the bits match
- SQL Query to find the last day of the month
- SQL Server "AFTER INSERT" trigger doesn't see the just-inserted row
- SQL Server 2005 Setting a variable to the result of a select query
- Order Of Execution of the SQL query
- How can I see all the "special" characters permissible in a varchar or char field in SQL Server?
- SQL Server - use columns from the main query in the subquery
More questions with similar tag
- Does SQL Profiler work with LocalDB?
- Bulk insert failing: Explicit value must be specified
- Refer to temporary table in Entity Framework query
- T-SQL Using Unsupported Column In Query
- Are there any considerations I should be aware of for setting up a database with an external table reference?
- Moving data between similar databases
- Azure SQL DB causing connection time out for stored procedures
- SQL Server: Why would i add ";1" to the end of a stored procedure name?
- SQL Pivot for multiple columns in a row
- And condition on Join table on the same field multiple times in Sequelize NodeJS?
- SQL - Counting INTs from a VARCHAR field
- SQL Server query performance on longer date range
- XML load is slow. Using text() when reading XML file with attribute-centric mapping
- SQL SELECT JOIN COLUMN ALIAS
- Notification Services custom delivery channel DLL trust issue
- DISTINCT with PARTITION BY vs. GROUPBY
- Is it possible to Decompile and read an SSIS package code?
- SQL best alternative to a LEFT JOIN and WHERE statement?
- how to substring an empty phrase in sql?
- GO causes error when used in EXEC: "Incorrect syntax near 'GO'."
- SQL Serve - How to group n lines to subnodes for xml path
- How can I make SSIS detect the record length when importing a flat file?
- select the lastest invoiced date from each customer invoice, with multiple invoices from same customer
- Dynamic Table Insert TSQL
- How to write a stored procedure to search data between 2 dates?
- while setting variable showing error in stored procedure
- tempdb SQL Server locking
- Sometimes bad Performance and Missing Index hint - Why?
- Is there a better way to identify time interval boundaries of a series pattern?
- Getting a single value from SQL with ADO.NET
Source:
stackoverflow.com