I have a business class. In this business class there are :
- a context to access database (via .dbml)
- Some methods
A SaveUser(User user)
method from this business class is called by a webservice. This method receive the modified User
object. How can I update the record in the database by the value from the object receive as parameter (the fields value have the expected values) ?
I tried this :
context.Users.Attach(user);
context.SubmitChanges();
I tried without the last line, same... no change in the database.
Any idea ?
Thanks,
Update 1
public class RightManager
{
private readonly DBDataContext dc;
public RightManager()
{
dc = new DBDataContext();
}
public User GetUser(int id)
{
User user = dc.GetTable<User>()
.Where(x => x.Id == id && x.IsEnable == true)
.SingleOrDefault<User>();
return user;
}
public void SaveUser(User user)
{
dc.Users.Attach(user);
}
}