码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2014-11-30 23:08:09      阅读:559      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   http   io   ar   color   os   sp   

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缓存问题 也不知道是不是缓存 问题

标签:des   style   blog   http   io   ar   color   os   sp   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!