寻找 MemberShip.GetAllUsers(startDate,endDate) 功能
我正在利用 .Net Membership 类创建一个用户批准界面。我有一个执行 Membership.GetAllUsers() 的页面,并将结果发送到数据网格。我通过 MembershipUser.IsApproved 过滤它们。
我的问题是由于我在 GetAllUsers() 时遇到的缓慢。
由于我不需要拉下所有用户,而是拉下所有 CreateDate 落在特定范围内的用户,我想知道是否有一种方法可以根据日期范围获取子集?
希望为有类似情况的人更新:
更新: 所以,我最终实际上没有使用下面的答案。尽管它确实正确地解决了具体问题。不管怎样,我真正的问题是,获取用户的子集(即那些需要“批准”的用户 - 因为我的管理员控制着这个(而不是用户))。我的解决方案是将新注册的用户分配给“awaitingapproval”角色,然后我能够获取 Roles.UsersInRole(“awaitingapproval”),向管理员显示这些角色,并具有“批准”用户的能力。然后,每个批准的用户将从“等待批准”中删除并分配给新角色。
I'm creating a user approval interface leveraging the .Net Membership class. I have a page that does a Membership.GetAllUsers(), and I spit the results to a datagrid. I filter them by MembershipUser.IsApproved.
My Issue is due to slowness I'm hitting while I GetAllUsers().
Since I don't need to pull down all of the users, but rather, say, all of the users with a CreateDate falling within a certain range, I'm wondering if there's a way to grab a subset based on date-range?
Wanted to Update for those in a similar situation:
UPDATE:
So, I ended up actually not using the answer below.. Although, it does address the specific question properly. Anyhow, my real problem was, grabbing a subset of Users (i.e. those requiring "approval" - Since my Admin holds control of this (not the users)). My solution was to assign newly signedup users to an "awaitingapproval" role, then I was able to grab Roles.UsersInRole("awaitingapproval"), display those to the Admin with the ability to "approve" a user. Each approved user is then dropped from "awaitingapproval" and assigned to a new role.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尽管 GetAllUsers() 有重载来根据索引返回用户子集(即一次用户“页面”),但您无法使用任何东西来将其基于这样的自定义逻辑。
我可能会编写一个继承基本成员资格提供程序的新类,并为 GetAllUsers() 添加新的重载。
您可以使用 Reflector 查看 System.Web.Security.SqlMembershipProvider 的源代码以 GetAllUsers() 的实现为起点。
Although there are overloads for GetAllUsers() to return a subset of users based on index (i.e. one "page" of users at a time), there is nothing that you could use to base it on custom logic like this.
I would probably write a new class that inherits the base membership provider and add a new overload for GetAllUsers().
You can use Reflector to see the source code for System.Web.Security.SqlMembershipProvider's implementation of GetAllUsers() as a starting point.
我宁愿说你可以使用 Linq 来查询值,但当我尝试它时,我得到了一个错误。
您可以编写一个存储过程来代替使用它,该存储过程根据给定的创建日期从数据库获取所有用户,并从该结果开始。
--> SQL数据库中会自动创建Membership,只需根据给定的参数修改aspnet_Membership_GetAllUsers存储过程
I would rather say that you could use Linq for querying values , but as I tried it I get an error.
Instead of using this you can write a stored procedure which gets all users from database by your given creating date and go over from that result.
--> There is on which Membership automatically creates in SQL Database, just Modify aspnet_Membership_GetAllUsers Stored Procedure by your given parameters