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?
A.
context.SaveChanges(SaveOptions.AcceptAllChangesAfterSave);
B.
context.SaveChanges(SaveOptions.DetectChangesBeforeSave);
C.
context.SaveChanges(SaveOptions.None);
D.
context.SaveChanges();
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
(http://msdn.microsoft.com/en-us/library/system.data.objects.saveoptions.aspx)