c# - updating an entity in entity framework -
c# - updating an entity in entity framework -
i have entity (terminalcertification) has relation other entities. want create user able update terminalcertification i'm not able update related object updated user. update code here:
public void updateterminalcertification(terminalcertification terminalcertification) { var lastcertification = db.terminalcertifications.find(terminalcertification.terminalcertificationid); if (lastcertification==null) throw new terminalcertificationnotfoundexception(terminalcertification) db.entry(lastcertification).currentvalues.setvalues(terminalcertification); } i have searched stackoverflow , found below code there not such objectstatemanager in dbcontext class.
objectstatemanager statemgr = db.objectstatemanager; objectstateentry stateentry = statemgr.getobjectstateentry(model); stateentry.setmodified(); what should do?
you can cast dbcontext iobjectcontextadapter has underlying objectcontext , utilize objectstatemanager off of that.
c# asp.net asp.net-mvc entity-framework-4
Comments
Post a Comment