EF 4和ASP.NET 4.0成员资格中的受限访问 [英] Restricted Access in EF 4 and ASP.NET 4.0 Membership

查看:111
本文介绍了EF 4和ASP.NET 4.0成员资格中的受限访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello,

几乎我们应用程序中的每个数据请求(或更新/插入)都需要将操作限制为属于当前ASP.NET Membership用户的行。

是否有一种简单的方法可以在每次数据访问中包含当前用户的Context?看起来为每个查询设置一个拦截器是有用的,我们可以在其中包含用户的ID。

使用ASP.NET 4和EF 4处理这种情况的最佳方法是什么?


作者:ASP.NET 3.5 For Dummies

Hello,

Almost every request (or update/insertion) for data in our application needs to restrict the operation to rows belonging to the current ASP.NET Membership user.

Is there a simple way to include the current user's Context in each data access? It seems like it would be useful to have an interceptor for each query where we could include the user's ID.

What's the best way to handle this scenario using ASP.NET 4 and EF 4?


Author: ASP.NET 3.5 For Dummies

推荐答案

你好Ken,

我们没有一般的查询拦截机制但是,您可以做的是将ObjectContext及其查询包装在存储库中,然后让存储库在实际执行之前始终将所有查询添加此附加过滤器。

这有帮助吗?
迭戈
Hi Ken,

We don't have general query interception mechanisms yet, but something you could do is wrap the ObjectContext and its queries in a repository, then have the repository always add this additional filter to all queries before they are actually executed.

Does this help?
Diego


这篇关于EF 4和ASP.NET 4.0成员资格中的受限访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆