PrepAway - Latest Free Exam Questions & Answers

Which line of code should you use?

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to develop an application.
You use the ADO.NET Entity Framework Designer to model entities. You retrieve an entity from an object context.
A different application updates the database. You need to update the entity instance to reflect updated values in the database.
Which line of code should you use?

PrepAway - Latest Free Exam Questions & Answers

A.
context.Refresh(RefreshMode.StoreWins, entity);

B.
context.LoadProperty(entity, �Client�, MergeOption.OverwriteChanges);

C.
context.AcceptAllChanges() ;

D.
context.LoadProperty(entity, “Server”, MergeOption.OverwriteChanges);

Explanation:
LoadProperty(Object, String) Explicitly loads an object related to the supplied object by the specified navigation property
and using the default merge option.
AcceptAllChanges Accepts all changes made to objects in the object context.
Refresh(RefreshMode, Object) Updates an object in the object context with data from the data source.

ObjectContext.Refresh Method (RefreshMode, Object)
(http://msdn.microsoft.com/en-us/library/bb896255.aspx)


Leave a Reply