4

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

3 Answers 3

2

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

0

hi answer with implementation can be found at below site

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.