Does my POST edit action overwrite all fields in EF?

元气小坏坏 提交于 2019-12-12 22:17:38

问题


Say I have a database record with 7 fields and I just want to edit the contents of field 1. So I hit my GET EDIT action, it renders the strongly typed view with my viewmodel and I go ahead and update field 1. However, my POST action contains 'mapping' for all fields as below. So will entity framework 'overwrite' all 6 other fields in the underlying database with the unchanged value or will it only just change field 1?

Just looking for further clarification after giving the previous related answer (c# edit method overwrite all or only save changes fields?) some more thought given that I am explicitly specifying each field in the edit method.

EDIT POST method extract -

db.entities.find(x)

            entity.field1= viewmodel.field1;
            entity.field2= viewmodel.field2;
            entity.field3= viewmodel.field3;
            entity.field4= viewmodel.field4;
            entity.field5= viewmodel.field5;
            entity.field6= viewmodel.field6;
            entity.field7= viewmodel.field7;

db.savechanges()

FYI - this is my first proper MVC app.

Many thanks

来源:https://stackoverflow.com/questions/21643480/does-my-post-edit-action-overwrite-all-fields-in-ef

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!