c# - How to use SqlCacheDependency with SqlCommand and MVC -
i have sqlcachedependency working mvc project i'm still bit confused on how working sqlcommand. goal dependency on couple fields changing within table, not in entire table changing.
so of right have set similar demo: http://sdeu.wordpress.com/2011/02/08/activate-asp-net-mvc3-caching-with-database-dependency/
my question is, can specify specific sqlcommand query depend on? , put code? i'd guess global.asax.cs.
i'd imagine this:
sqlcommand cmd = connection.createcommand(); cmd.commandtext = "select fieldname1, fieldname2 myschema.sometable"; sqlcachedependency mydependency = new sqlcachedependency(cmd);
but how would use in controller? maybe:
[outputcache(duration = int32.maxvalue, sqldependency = mydependency)]
also, required create table triggers , cache table(aspnet_sqlcachetablesforchangenotification) on database if use sqlcommand dependency?
thanks help.
Comments
Post a Comment