本文介绍了ObjectStateManager没有定义问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正面临着 ObjectStateManager
的问题。
我是使用
System.Data.Entity
和 System.Data.Objects
但是,它没有显示 ObjectStateManager
。
I am using
both System.Data.Entity
and System.Data.Objects
however it shows no definition for ObjectStateManager
.
SampleContext db = new SampleContext();
Employees employeeFromDB = db.Employees.Single(x => x.Id == employee.Id);
employeeFromDB.FullName = employee.FullName;
employeeFromDB.Gender = employee.Gender;
employeeFromDB.Age = employee.Age;
employeeFromDB.HireDate = employee.HireDate;
employeeFromDB.Salary = employee.Salary;
employeeFromDB.PersonalWebSite = employee.PersonalWebSite;
db.ObjectStateManager.ChangeObjectState(employeeFromDB, System.Data.EntityState.Modified);
db.SaveChanges();
return RedirectToAction("Details", new {Id = employee.Id});
推荐答案
来自:
var manager = ((IObjectContextAdapter)db).ObjectContext.ObjectStateManager;
这篇关于ObjectStateManager没有定义问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!