1
我使用SqlCacheDependency
緩存了DataSet
中的結果。SQL緩存相關性問題
叫了頁面加載
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中使用一個簡單的代碼:
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自己手動修改。我重新加載頁面,更改後的數據立即可見。
哪一行產生問題或者是缺少什麼?