按日期降序获取被禁止用户的列表
我正在做这样的事情来获取所有已被阻止的用户的列表:
public IQueryable<Aspnet_User> GetBannedUsers()
{
return db.Aspnet_Memberships.Where(x => x.IsApproved == false).Select(x => x.Aspnet_User);
}
我这样做是为了阻止用户:
MembershipUser user = Membership.GetUser(username);
if (user != null)
{
user.IsApproved = isApproved;
Membership.UpdateUser(user);
}
我如何获取按被禁止日期排序的被禁止用户的列表。 最近被禁止的应该排在第一位。
Im doing something like this to get a list of all users that have been blocked:
public IQueryable<Aspnet_User> GetBannedUsers()
{
return db.Aspnet_Memberships.Where(x => x.IsApproved == false).Select(x => x.Aspnet_User);
}
Im doing this to block users:
MembershipUser user = Membership.GetUser(username);
if (user != null)
{
user.IsApproved = isApproved;
Membership.UpdateUser(user);
}
how can i get the list of banned users ordered by date they were banned.
most recently banned should be first.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
默认情况下,asp.net 成员资格不存储此日期,因此您必须使用解决方法。一个巧妙的方法是引入您自己的表,但我建议滥用 LastLoginDate。只要用户未正确登录,默认机制就不会触及此日期(您的 !isApproved 将阻止发生这种情况)。
修改代码以阻止用户:
按禁止日期排序的代码,从 @Femaref 的答案复制粘贴:
By default, asp.net membership does not store this date, so you'll have to use a workaround. A neat approach would be to introduce your own table, but I suggest abusing the LastLoginDate. The default mechanism will not touch this date as long as the user doesn't login properly (which your !isApproved will prevent from happening).
Modified code to block user:
Code to sort on banned date, copy pasted from @Femaref's answer: