zoukankan      html  css  js  c++  java
  • 跪求 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));
    }

    }

    }
    }

    求大神解答  

  • 相关阅读:
    C# 操作Orcle数据库
    WinDbg排查CPU高的问题
    NetCore微服务实战体系:日志管理
    NetCore微服务实战体系:Grpc+Consul 服务发现
    解惑求助-关于NetCore2.2中间件响应的问题
    EF Join连接查询的坑
    给DataTable添加行的几种方式
    [C#] 折腾海康威视的人体测温 模组
    [WPF 学习] 15.播放百度合成的语音
    [WPF 学习] 14.PlaceHolder的简单实现
  • 原文地址:https://www.cnblogs.com/520cc/p/4133819.html
Copyright © 2011-2022 走看看