PrepAway - Latest Free Exam Questions & Answers

You need to execute custom logic when an entity is attached to the ObjectContext

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to develop an application
that uses the Entity Framework. You need to execute custom logic when an entity is attached to the
ObjectContext. What should you do?

PrepAway - Latest Free Exam Questions & Answers

A.
Create a partial method named OnStateChanged in the partial class for the entity.

B.
Create a partial method named OnAttached in the partial class for the entity.

C.
Create an event handler to handle the ObjectStateManagerChanged event.

D.
Create an event handler to handle the ObjectMaterialized event.

Explanation:
ObjectStateManagerChanged Occurs when entities are added to or removed from the state
manager. ObjectMaterialized Occurs when a new entity object is created from data in the data
source as part of a query or load operation.
ObjectStateManagerChanged Event
(http://msdn.microsoft.com/enus/library/system.data.objects.objectstatemanager.objectstatemanagerchanged.
aspx)
ObjectMaterialized Event
(http://msdn.microsoft.com/enus/library/system.data.objects.objectcontext.objectmaterialized.aspx)


Leave a Reply