I use LINQ queries in my ASP.NET MVC application and want to use OutputCache in some of my Actions.
I hear this should be possible with CommandNotifications. But those seem to only go for self-created SQLCommands, or am I wrong?
Can I manually tell SQL server to send SQLDependency notifications if certain tables change? And if yes, how can I attach them to the OutputCache?
Another side question: Can you do this with strongly types views too?
Thank you in advance…
You can give a shot to LinqToCache project. It does exactly what you ask for, hook a SqlDependency on any LINQ query, as long as the query sent to the SQL Server conforms to the Query Notification restrictions. For Linq-to-SQL this mainly consist of specifying the full two part name for tables in the model designer (ie.
dbo.Tablenot onlyTable). For Linq-to-EF unfortunately the way EF chooses to format the query is incompatible with QN restrictions.