Implement INotifyPropertyChanged on generated Entity Framework classes

前端 未结 5 1060
有刺的猬
有刺的猬 2020-11-30 11:11

I have an SQL DB and am implementing a WPF UI to update it. If I use EF5 to generate the classes from the DB, how can I implement INotifyPropertyChanged on the generated cla

5条回答
  •  一个人的身影
    2020-11-30 11:47

    Make all your EF generated classes inherit from a class which implements the INotifyPropertyChanged interface (using the non-generated partial classes you probably already defined). Add a method to this base class, which raises the PropertyChanged event with an empty string as PropertyName. Then, every time you call this method on an EF generated class instance, all its modified properties will be refreshed in your WPF UI.

提交回复
热议问题