0 votes
1 view
in SQL by (20.3k points)

Here's the table

Users

UserId

UserName

Password

EmailAddress

and code...

public void ChangePassword(int userId, string password){

//code to update the password...

}

1 Answer

0 votes
by (40.4k points)

Try the below code:

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();

  }

}

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...