Select from following answers:- After attaching the updated product, call the ApplyOriginalValues method of the Product's ObjectSet with the original Product entity.

- Replace the call to Attach with a call to the ObjectContext's AddObject method.
- Call the ObjectContext's method AcceptAllChanges method before calling SaveChanges.
- All Above
In the Entity Framework, objects can be attached to, or detached from, an object context. Objects that are attached to an object context are tracked and managed by that object context. When a query is executed inside an object context in the Entity Framework, the returned objects are automatically attached to the object context. You can attach objects that have been returned from a remote method call or web service by calling the Attach method. Entities are attached in an Unchanged state. The ApplyOriginalValues method sets the OriginalValues of the ObjectStateEntry instance to match the values of the supplied object. When changes are applied to the original values of an object in an Unchanged state, the EntityState is changed to Modified. The ApplyOriginalValues method is used to set the original values of an object to the properties of an object outside the ObjectContext, such as detached objects that are received by a web service.
Show Correct Answer
Source: MeasureUp.Com | |
Alert Moderator