You need to create and persist a relationship between person1 and territory1

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 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 also 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 territory1. What should you do?

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 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 also 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 territory1. What should you do?

A.

1. Detach person1 from objectContext1.
2. Attach person1 to objectContext2.
3. Set the SalesTerritory property of person1 to territory1.
4. Call SaveChanges on objectContext2.

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

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

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



Leave a Reply 0

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