NIF NIF - 1 year ago 135
C# Question

Entity Framework : how to raise an event on Property Change?

When I use DataSet, there is possiblity to raise events on RowChanging, RowChanged, ColumnChanging, ColumnChanged, etc...

Ho to do the same with objects from Entity Framework ?

Thank's for your help.

Answer Source

Entities already implement the PropertyChanged event since they implement System.ComponentModel.INotifyPropertyChanged. If you want to catch changes to your entieis, you can just subscribe to that.

Also note that entities support the following two partial methods—the second of which should give you the equivalent of "RowChanging"—that you can override if you'd like to respond to changes within your class:

protected override void OnPropertyChanged(string property) {}

protected override void OnPropertyChanging(string property) {}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download