1

I have a table with columns username, password. Data can be updated by admin for the table.

Now I want to add a new column named IsAgree (as a flag), it need to set when user logs in for the first time. But while setting data, it should not affect other column data, I will only send usename and Isagree flag as an object.

flgDetail = { usename:"vis" Isallowed:True }

[Route("api/TermsAndCondition/setflag")]
public IHttpActionResult post(FlagDetails FlagDetail)
{
    var user = _context.table.Where(s => s.UserName == flagDetail.UserName);
}

Should I use post or put?

How can I update only one column?

And it should not affect other columns.

4
  • Is _context.Configuration.AutoDetectChangesEnabled set to true? Commented Aug 29, 2016 at 6:33
  • where it has to set? Commented Aug 29, 2016 at 6:38
  • 1
    If you have not changed it it should be set to true. It is usually managed inside context, for example in the constructor. But you can check it where you want. bool isEanbled = _context.Configuration.AutoDetectChangesEnabled;. If AutoDetectChanges is enabled, EF will update only changed properties Commented Aug 29, 2016 at 6:40
  • Did you try to change the IsAgree of user variable and call SaveChanges? Since you got it from the context with your query, setting the IsAgree will only affect this field. Try this and post if you get any problems Commented Aug 29, 2016 at 13:47

1 Answer 1

1

you can use either post or put.It's not a problem.You can update it as shown below.

[Route("api/TermsAndCondition/setflag")]
public IHttpActionResult post(FlagDetails flagDetail)
{
    var user = _context.table.Where(s => s.UserName == flagDetail.UserName);
    user.IsAgree =flagDetail.Isallowed;
   _context.SaveChanges()
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.