What are two possible code segments that you can use to achieve this goal?

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. The application includes selftracking entities as shown in the following diagram.

There is a Person entity named person1 that has Track Changes turned on. You need to delete all email addresses that are associated with person1 by using an ObjectContext named context. What
are two possible code segments that you can use to achieve this goal? (Each correct answer presents
a complete solution. Choose two).

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. The application includes selftracking entities as shown in the following diagram.

There is a Person entity named person1 that has Track Changes turned on. You need to delete all email addresses that are associated with person1 by using an ObjectContext named context. What
are two possible code segments that you can use to achieve this goal? (Each correct answer presents
a complete solution. Choose two).

A.
foreach(var email in person1.EmailAddresses)
{
email.MarkAsDeleted();
}
context.SaveChanges();

B.
while(person1.EmailAddresses.Count() > 0)
{
person1.EmailAddresses.RemoveAt(0);
}
context.SaveChanges();

C.
person1.EmailAddresses = null;
context.SaveChanges();

D.
person1.EmailAddresses = new
TrackableCollection<EmailAddress>();
context.SaveChanges();

Explanation:
Working with Self-Tracking Entities
(http://msdn.microsoft.com/en-us/library/ff407090.aspx)

Working with Sets of Self-Tracking Entities
(http://blogs.msdn.com/b/adonet/archive/2010/06/02/working-with-sets-of-self-trackingentities.aspx)



Leave a Reply 0

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