tags:

views:

25

answers:

3

HI Can any one explain me how to implement SQL Dependency Caching in Asp.Net?

A: 

How you implement SQL dependency caching will depend on the version of SQL server you are using. I would suggest reading this MSDN article to get a better understanding of how it hangs together.

Andy Rose
Am using SQL Server 2008
programmer4programming
A: 

See David Hayden's article on the subject for an example.

Generally you connect the dependency to a command and add the dependency when inserting into the cache.

var command = new SqlCommand("SELECT something FROM dbo.ATable", connection);
var dependency = new SqlCacheDependency(command);
var result = ObtainResultUsingThe(command);

Cache.Insert("CacheKey", result, dependency);

Observe that special rules apply for your queries. Among others:

  • Named columns must be selected (no SELECT *)
  • Must use fully qualified name of table (e.g. dbo.ATable)

Edit:

For using the dependency in caching an entire page, you can follow this example.

PHeiberg
A: 

hi answer with implementation can be found at below site

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

hari