ASP.NET Identity 2 UserManager get all users async

前端 未结 2 1451
余生分开走
余生分开走 2020-12-16 10:52

Can somebody tell if there is a way to get all users async in ASP.NET Identity 2?

In the UserManager.Users there is nothing async or find all async or s

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-16 11:35

    Expanding on DavidG's answer for .NET Core 2.1 you would need to user IdentityUser instead of User, as well as you will have to use your context directly.

    public async Task> GetUsersAsync()
    {
        using (var context = new ApplicationDbContext())
        {
            return await context.Users.ToListAsync();
        }
    }
    

提交回复
热议问题