跪求 EF缓存问题 也不知道是不是缓存 问题

1.数据库里面查的结果  

2 vs里面查的结果   为什么 不是16 而是2   

下面是代码 

/// <summary>
/// 权限检查
/// </summary>
public class checkPermission : AuthorizeAttribute
{
AliexpressEntities aliexpressEntities = new AliexpressEntities();
public override void OnAuthorization(AuthorizationContext filterContext)
{
HttpContextBase context = filterContext.HttpContext;
var url = "/login";

if (context.Session["user"] == null)
{
context.Response.Write(string.Format("<script> window.top.location.href='{0}';</script>", url));
}
else
{
var user = context.Session["user"] as YH_User;
string Controller = null;
string action = null;
if ( filterContext.ParentActionViewContext!=null) //部分试图
{
action= filterContext.ParentActionViewContext.RouteData.Values["action"].ToString().ToLower();
Controller = filterContext.ParentActionViewContext.RouteData.Values["controller"].ToString().ToLower();

}
else
{
Controller = (filterContext.ActionDescriptor).ControllerDescriptor.ControllerName.ToLower();
action = filterContext.ActionDescriptor.ActionName.ToLower();
}

var role = aliexpressEntities.SYS_User_Role.Where(p => p.isActive == true && p.UserId == user.userId).Single();

//这里获取不到最新的数据


//所属角色下所有的权限
var IsSystemModel = aliexpressEntities.SYS_SystemModel.Where(p => p.isActive == true && aliexpressEntities.SYS_Role_Permissions.Where(M => M.isActive == true && M.RoleId == role.RoleId).Select(M => M.SystemModelId).Contains(p.SystemModelId) && p.Controllers.ToLower() == Controller && p.Action.ToLower() == action).FirstOrDefault();
if (IsSystemModel==null)
{
context.Response.Write(string.Format("<script> window.top.location.href='{0}';</script>", url));
}

}

}
}

求大神解答  

原文地址:https://www.cnblogs.com/520cc/p/4133819.html