SQL Caching and Entity Framework

前端 未结 2 1688
深忆病人
深忆病人 2021-02-04 16:06

I have put together a small ASP.NET MVC 2 site that does some very extensive date mining/table-joins/etc.

Using MVC, I have a controller that returns the data in many

相关标签:
2条回答
  • 2021-02-04 16:55

    It is possible to wrap any arbitrary LINQ query in a SqlDependency, including EF Linq queries, see LinqToCache. But unfortunately the way EF chooses to formulate the SQL for the queries, even the most simple from t in context.table select t, is incompatible with the Query Notificaiton restriction and the SqlDependency is invalidated straight away as an invalid statement. I have talked about this in SqlDependency based caching of LINQ Queries.

    What you can do is use SqlChangeMonitor with straightforward SqlCommand objects constructed as simple SELECT ... FROM Table on your tables that are likely to change. You need to understand that there is a balance between the cost of setting up notifications and the cost of polling, if your tables change frequently then monitoring for changes could turn out to be more expensive than polling. See this article The Mysterious Notification to understand how QN works and what is the cost of monitoring.

    0 讨论(0)
  • 2021-02-04 17:04

    hi answer with implementation can be found at below site

    http://harismile.wordpress.com/2010/09/09/mvc-with-ef-sqldependencycache/

    0 讨论(0)
提交回复
热议问题