阅读背景:

无法创建“WebApplication2.Models.Role”类型的常量值。在此上下文中仅支持基元类型或枚举类型

来源:互联网 
[HttpGet]
public ActionResult Edit(int id)
{
    var userToEdit = _db.AuthLogin.Where(user => user.Id == id).SingleOrDefault();
    if (userToEdit == null)
        return HttpNotFound();


    return View(new EditUser()
    {
        Email = userToEdit.Email,
        UserName = userToEdit.UserName,
        Password = userToEdit.Password,
        Roles = _db.Roles.Select(role => new RoleCheckBox
        {
            Id = role.Id,
            IsChecked = userToEdit.Roles.Contains(role),
            Name = role.Name
        }).ToList()
    });
}
[HttpGet]
public ActionResult Edit(int id)
{
  



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: