【问题标题】:Is there a way to query for all users and with a where clause with the new UserManager and UserStore in Asp.net MVC5?有没有办法在 Asp.net MVC5 中使用新的 UserManager 和 UserStore 查询所有用户并使用 where 子句?
【发布时间】:2013-11-08 04:01:33
【问题描述】:

我想知道是否有办法使用新的内置用户方法查询所有用户,或者我应该为应用程序用户创建一个存储库?

带有实体框架 6 和 c# 的 Asp.Net MVC5

【问题讨论】:

    标签: asp.net-mvc asp.net-mvc-5 asp.net-identity


    【解决方案1】:

    所以您不能通过 1.0 RTM 中的 UserManager API,这在 1.1 中可以通过 UserManager.Users 成为 IQueryable。

    如果您存储用于构造 UserManager 的 DbContext/UserStore,即 myApplicationDbContext.Users,则可以通过 DbContext 本身执行此操作

    【讨论】:

    • 当大约。是否会增加多用户多角色、删除用户等功能?
    • 删除用户也在 1.1 中,alpha1 版本应该很快就会发布。像旧成员资格这样的显式 API 可能不支持将许多用户添加到多个角色。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-05
    • 1970-01-01
    • 1970-01-01
    • 2023-03-26
    • 1970-01-01
    • 2020-12-20
    相关资源
    最近更新 更多