Hi coders,
I am fetching a user + roles with eager loading and it is fetching all the columns i.e. even the password column.
var user = db.Users
.Include(p => p.Roles)
.Where(x => x.UserName == userName)
.FirstOrDefault();
I modified my code by creating a new model class object and transfering the data to it.
UserModel currentUser = new UserModel();
currentUser.Id = user.Id;
currentUser.UserName = user.UserName;
currentUser.Email = user.Email;
currentUser.DateCreated = user.DateCreated;
currentUser.Roles = user.Roles;
return currentUser;
Is the above code valid or should I create a View in the database to fetch user record without password.
Thanks in advance
Regards
Kiran