我想在数据库视图中显示更新的数据。我正在使用具有SQL依赖项的输出缓存。
下面是控制器:
[OutputCache(Duration = 3600, Location = System.Web.UI.OutputCacheLocation.Server)]
public ActionResult List()
{
var project = unitOfWork.ProjectRepository
.Get().AsEnumerable()
.Where(p => p.IsDeleted == 0)
.Select(p => new Project { ProjectID = p.ProjectID, Name = p.Name })
.OrderBy(p => p.Name)
.ToList();
string jsondata = new JavaScriptSerializer().Serialize(project);
return Json(jsondata, JsonRequestBehavior.AllowGet);
}
web.config
:
<caching>
<sqlCacheDependency enabled="true" pollTime="2000">
<databases>
<add name="DSS" connectionStringName="DocumentStorageContext"/>
</databases>
</sqlCacheDependency>
</caching>