This is the current basic code :
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit(Registration registration)
{
if (ModelState.IsValid)
{
db.Entry(registration).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
return View(registration);
}
I have around 15 fields in Registration table , how ever i just want to update the "Date" field , the object that i receive here is "registration" which only has value for a date , but the current code updates all the entries , what i want is to just update the "Date" field , whose value i have got in "registration"
Help would be much appreciated :)
Try this
Update : as per answer in this post
use this for single record updation and i assuming that RegistrationId in your Registration table.
Attach it to the context in the
Unchanged
state, and only setDate
as modified.You said the incoming entity only has
Date
filled in, hopefully there's an Id too. :)