How to update only one column value in database using Entity Framework? -
i have table columns username
, password
. data can updated admin table.
now want add new column named isagree
(as flag), need set when user logs in first time. while setting data, should not affect other column data, send usename , isagree flag 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 use post or put?
how can update 1 column?
and should not affect other columns.
you can use either post
or put
.it's not problem.you can update 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() }
Comments
Post a Comment