I can successfully listen to changes on Entity Framework child EntityCollection if the action is add or delete but cannot find the way to listen to changes if the child class property value was updated.
More specifically, in the below, how can I access the property name that was changed on the child ("Employee") class to run some business logic on the parent ("Company") class?
Public Sub New()
AddHandler Me.employees.AssociationChanged, AddressOf employees_AssociationChanged
End Sub
Private Sub employees_AssociationChanged(ByVal sender As Object, ByVal e As CollectionChangeEventArgs)
Dim act As CollectionChangeAction = e.Action
Dim employeeOnOtherEnd As employee = CType(e.Element, employee)
If Not employeeOnOtherEnd Is Nothing Then
If act = CollectionChangeAction.Add Then
'logic when new employee added
ElseIf act = CollectionChangeAction.Remove Then
'logic when new employee was deleted
End If
'I want to run some business logic here if some employee property value was updated... How to do that?
End If
End Sub
I have INotifyPropertyChanged but I don't want to place any code inside employee class to affect the company class directly. Instead I want to catch the change in company class and run the logic there. I'd like to see the Visual Basic example for this.