我正在DataSet
使用SqlCacheDependency
.
在页面加载中调用了一个简单的代码
string conn= WebConfigurationManager.ConnectionStrings["NorthwindEntities"].ConnectionString;
SqlConnection con = new SqlConnection(conn);
string query = "SELECT EmployeeID, FirstName, LastName, City FROM dbo.Employees";
SqlCommand cmd = new SqlCommand(query, con);
SqlDataAdapter dadapter= new SqlDataAdapter(cmd);
数据集用法:
DataSet ds = new DataSet();
dadapter.Fill(ds, "Employees");
并将其缓存为:
SqlCacheDependency empDependency = new SqlCacheDependency(cmd);
Cache.Insert("Employees", ds, empDependency, DateTime.Now.AddMinutes(10),Cache.NoSlidingExpiration);
但是,我运行页面,在网格视图中加载数据,然后从 SQLServer 本身手动修改。我重新加载页面,更改的数据立即可见。
哪条线正在制造问题或缺少任何东西?