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 e-mail 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.
For Each email in person1.EmailAddresses
email.MarkAsDeleted()
Next
context.SaveChanges()
B.
While (person1.EmailAddresses.Count() > 0)
person1.EmailAddresses.RemoveAt(0)
End While
context.SaveChanges()
C.
person1.EmailAddresses = Nothing
context.SaveChanges()
D.
person1.EmailAddresses = New _
TrackableCollection(Of 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)