首页 > 其他 > 详细

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

时间:2014-11-30 23:07:41      阅读:555      评论:0      收藏:0      [点我收藏+]

1.数据库里面查的结果  

bubuko.com,布布扣

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

bubuko.com,布布扣

下面是代码 

/// <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));
}

 

}

}
}

求大神解答  

 

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

原文:http://www.cnblogs.com/520cc/p/4133819.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!