What should you do?

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

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

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/en-us/library/system.data.objects.objectstatemanager.objectstatemanagerchanged.aspx)

ObjectMaterialized Event
(http://msdn.microsoft.com/en-us/library/system.data.objects.objectcontext.objectmaterialized.aspx)



Leave a Reply 0

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