I can't seem to get the following code working.
I would like to use the following code
db.Entry(user).Property(x => x.Password)
Instead of
db.Entry(user).Property("Password")
This is a code snippet from an answer which can be found here Link.
public void ChangePassword(int userId, string password)
{
var user = new User() { Id = userId, Password = password };
using (var db = new MyEfContextName())
{
db.Users.Attach(user);
db.Entry(user).Property(x => x.Password).IsModified = true;
db.SaveChanges();
}
}
My current usings
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Linq.Expressions;
using System.Data.Entity.Infrastructure;