I have a standard MVC application using the out-of-the-box code generated with the scaffolding for application functionality (CRUD). I'm trying to evaluate whether a particular field has been changed in order to accomplish additional tasks on my data. Apparently my idea of how OriginalValues and CurrentValues isn't the way it is actually implemented (ugh!). Any ideas on how to compare the values to make this happen? Thanks in advance...
[HttpPost]
public ActionResult Edit(Address address)
{
if (ModelState.IsValid)
{
string st1 = db.Entry(address).Property(p => p.locationTypeId).CurrentValue.ToString();
//string st2 = db.Entry(address).Property(p => p.locationTypeId).OriginalValue.ToString();
bool bLocationTypeChanged = false;
db.Entry(address).State = EntityState.Modified;
db.SaveChanges();
// Other stuff happens here
return RedirectToAction("Index");
}
ViewBag.locationTypeId = new SelectList(db.LocationTypes, "locationTypeId", "name", address.locationTypeId);
return View(address);
}