Entity Framework Modify Detached Object

前端 未结 2 1855
忘了有多久
忘了有多久 2021-01-25 22:40

I have some confusion, stemming from this http://msdn.microsoft.com/en-us/library/vstudio/bb896248(v=vs.100).aspx regarding modifying a detached object.

That seems to in

2条回答
  •  太阳男子
    2021-01-25 23:19

    I think you're just misreading the MSDN article..

    From the MSDN Definition of ApplyOriginalValues:

    Copies the scalar values from the supplied object into set of original values for the object in the ObjectContext that has the same key.

    From the MSDN Definition of ApplyCurrentValues:

    Copies the scalar values from the supplied object into the object in the ObjectContext that has the same key.

    Which is exactly the behavior you're seeing. ApplyOriginalValues goes back to the database and updates the values. ApplyCurrentValues uses the values in the object that you have, so you can update the changes.

提交回复
热议问题