Jul 16, 2019 05:48 AM|Rena Ni|LINK
I still get the error though after updating the service.
As mgebhard said, you could use user.propertyName .And then you also need to change the IEnumerable<User> type to List<User> type like below:
public List<User> GetUsers()
According to your request, do you want to get the single item of the userlist? If so ,I suggest that you could define a property of UserId in User class, and receive an id in Details() method. Here is a working demo:
public IEnumerable<User> GetUsers()
var userList = new List<User>();
Email = "email@example.com",
PhoneNumber = "555-555-5555",
Username = "test"
Email = "firstname.lastname@example.org",
PhoneNumber = "317-455-5555",
Username = "anotheruser"
public ActionResult Details(int id)
var user = _userService.GetUsers().Where(u=>u.UserId==id).FirstOrDefault();
var model = new UserViewModel()
UserName = user.Username,
Enabled = user.Enabled