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.0 to develop an application.
You use the ADO.NET Entity Framework Designer to model entities.
The application includes self-tracking entities as shown in the following diagram.

There is a Person entity names person1 that has TrackChanges turned on.
You need to delete all e-mail addresses that are associated with person1 by using an ObjectContext.

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.0 to develop an application.
You use the ADO.NET Entity Framework Designer to model entities.
The application includes self-tracking entities as shown in the following diagram.

There is a Person entity names person1 that has TrackChanges turned on.
You need to delete all e-mail addresses that are associated with person1 by using an ObjectContext.

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-tracking-entities.aspx)



Leave a Reply 0

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