视图中未显示更新的数据(MVC 5,EF,SQL依赖关系)

时间:2018-07-18 01:29:21

标签: c# sql-server asp.net-mvc entity-framework sqldependency

我想在数据库视图中显示更新的数据。我正在使用具有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>

0 个答案:

没有答案