tags:

views:

45

answers:

1

What are the key differences between these and when should they be used? My initial understanding was that SqlCacheDependency used polling but I've read it doesn't have too for ASP.NET 2.0. I want to know which is most appropriate for caching of linq queries under ASP.NET web server. This will be ASP.NET 3.5.

SqlCacheDependency http://forums.asp.net/p/1010106/1353521.aspx

SqlCacheDependency http://msdn.microsoft.com/en-us/library/system.web.caching.sqlcachedependency.aspx

SqlDependency http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldependency.aspx

The SqlCacheDependency class also supports integration with the System.Data.SqlClient.SqlDependency class when using a SQL Server 2005 database. The query notification mechanism of SQL Server 2005 detects changes to data that invalidate the results of an SQL query and removes any cached items associated with the SQL query from the System.Web.Caching.Cache.

+1  A: 

Query Notification is the underlying technology. SqlNotificationRequest is the ADO.Net client support. SqlDependency is the ADO.Net infrastructure to automate the deployment of temporary objects needed by SqlNotificationRequest. SqlCacheDependency uses SqlDependency to integrate it with the ASP caching infrastructure. See more at The Mysterious Notification.

Note on them work with LINQ. See LinqToCache for a project that leverages Query Notifications with LINQ queries, and also explains why the vast majority of LINQ queries cannot use Query Notifications.

Remus Rusanu