Which line of code should you use?

You develop a Microsoft .NET Framework 4 application that uses the Entity Framework to store
entities in a Microsoft SQLServer2008 database. While the application is disconnected from the
database, entities that are added or modified are serialized to a local file. The next time the
application connects to the database, it retrieves a Customer entity from the database by using an
object context named context and stores the entity in a variable named remoteCustomer. The
application then deserializes the Customer entity from the local file and stores the entity in a
variable named localCustomer. The remoteCustomer and the localCustomer variables have the same
entity key. You need to ensure that the offline changes to the Customer entity are persisted in the
database when the ObjectContext.SaveChanges() method is called. Which line of code should you
use?

You develop a Microsoft .NET Framework 4 application that uses the Entity Framework to store
entities in a Microsoft SQLServer2008 database. While the application is disconnected from the
database, entities that are added or modified are serialized to a local file. The next time the
application connects to the database, it retrieves a Customer entity from the database by using an
object context named context and stores the entity in a variable named remoteCustomer. The
application then deserializes the Customer entity from the local file and stores the entity in a
variable named localCustomer. The remoteCustomer and the localCustomer variables have the same
entity key. You need to ensure that the offline changes to the Customer entity are persisted in the
database when the ObjectContext.SaveChanges() method is called. Which line of code should you
use?

A.
context.ApplyOriginalValues(“Customers”, remoteCustomer);

B.
context.ApplyOriginalValues(“Customers”, localCustomer);

C.
context.ApplyCurrentValues(“Customers”, remoteCustomer);

D.
context.ApplyCurrentValues(“Customers”, localCustomer);

Explanation:
http://msdn.microsoft.com/en-us/library/dd487246.aspx



Leave a Reply 0

Your email address will not be published. Required fields are marked *