70-516 · Question #205
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create an application. The application connects to a Microsoft SQL Server database. You use the ADO.NET Entity Framework to…
The correct answer is B. context.SaveChanges(SaveOptions.DetectChangesBeforeSave). None Changes are saved without the DetectChanges or the AcceptAllChangesAfterSave() methods being called. AcceptAllChangesAfterSave After changes are saved, the AcceptAllChangesAfterSave() method is called, which resets change tracking in the ObjectStateManager…
Question
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create an application. The application connects to a Microsoft SQL Server database. You use the ADO.NET Entity Framework to manage persistence-ignorant entities. You create an ObjectContext instance named context. Then, you directly modify properties on several entities. You need to save the modified entity values to the database. Which code segment should you use?
Options
- Acontext.SaveChanges(SaveOptions.AcceptAllChangesAfterSave);
- Bcontext.SaveChanges(SaveOptions.DetectChangesBeforeSave);
- Ccontext.SaveChanges(SaveOptions.None);
- Dcontext.SaveChanges();
How the community answered
(33 responses)- A6% (2)
- B82% (27)
- C3% (1)
- D9% (3)
Explanation
None Changes are saved without the DetectChanges or the AcceptAllChangesAfterSave() methods being called. AcceptAllChangesAfterSave After changes are saved, the AcceptAllChangesAfterSave() method is called, which resets change tracking in the ObjectStateManager. DetectChangesBeforeSave Before changes are saved, the DetectChanges method is called to synchronize the property values of objects that are attached to the object context with data in the ObjectStateManager. SaveOptions Enumeration
Topics
Community Discussion
No community discussion yet for this question.