Reputation: 4432
I have a handler that causes a sub context_SaviningChanges to be executed when an update is made to one of the entity objects like so:
AddHandler Me.SavingChanges, AddressOf context_SavingChanges
I want to have specific code executed for each entity that is being updated. So, if it is a "phone" entity I want to trigger one piece of code but if it is a "buildings" entity I want to trigger another piece of code. In pseudo code I want to do something like this:
For Each entry as ObjectStateEntry in DirectCast(sender, ObjectContext).ObjectStateManager.GetObjectStateEntries(EntityState.Modified)
If entry.entity("phone") Then
... code goes here for phone changes ...
ElseIf entry.entity("building")
... code goes here for building changes ...
Else
... code goes here for other entity changes ...
Next
Upvotes: 0
Views: 69
Reputation: 26782
You can check for the type of the ObjectStateEntry.Entity [msdn]:
If TypeOf entry.Entity Is Phone Then
' ...
End If
Upvotes: 3