PrepAway - Latest Free Exam Questions & Answers

What should you do?

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 as shown in the following diagram.

You create an ObjectContext instance named objectContext1 and use it to create a SalesPerson instance named person1.
You create an ObjectContext instance named objectContext2 and use it to create a SalesTerritory instance named territory1.
You need to create and persist a relationship between person1 and terrotory1. What should you do?

PrepAway - Latest Free Exam Questions & Answers

A.
Detach person1 from objectContext1.
Attach person1 to objectContext2.
Set the SalesTerritory property of person1 to territory1.
Call SaveChanges on objectContext2.

B.
Attach person1 to objectContext2.
Attach territory1 to objectContext1.
Set the SalesTerritory property of person1 to territory1.
Call SaveChanges on both objectContext1 and objectContext2.

C.
Detach person1 from objectContext1.
Detach territory1 from objectContext2.
Set the SalesTerritory property of person1 to territory1.
Call Refresh on both objectContext1 and objectContext2.

D.
Attach person1 to objectContext2.
Detach territory1 from objectContext2.
Set the SalesTerritory property of person1 to territory1.
Call Refresh on objectContext1.


Leave a Reply