ASP身份:渴望加载用户

时间:2018-02-27 12:28:11

标签: c# asp.net-mvc asp.net-identity

我在IdentityUser中添加了一个名为ClientID的属性,它与FK的表客户端正确相关。

AspNetUsers with ClientId FK

现在我想用他的客户名称(来自Clients表)来检索用户。 如何在context.Users中创建Include函数?

    public ActionResult Users(string filter = "all")
    {

       context = new IdentityContext();
        var allusers = context.Users.ToList();

        List<UserViewModel> model = allusers.Select(user => new UserViewModel { Username = user.UserName,FullName=user.FirstName + " "+ user.LastName, Id = user.Id, Roles = string.Join(",", UserManager.GetRoles(user.Id))}).ToList();

        return View(model);
    }

0 个答案:

没有答案