The LINQ-to-SQL class does not implement INotifyPropertyChanging & INotifyPropertyChanged if pulled from a local database

I changed my data source in my LINQ-to-SQL class (the old delete and drag and drop method), and was surprised to see that the INotifyPropertyChanging and INotifyPropertyChanged interfaces are no longer implemented in the generated classes (MyDb.designer. CS).

Methods for individual fields came from this kind ...

[Column(Storage="_Size", DbType="NVarChar(100)")] public string Size { get { return this._Size; } set { if ((this._Size != value)) { this.OnSizeChanging(value); this.SendPropertyChanging(); this._Size = value; this.SendPropertyChanged("Size"); this.OnSizeChanged(); } } } 

To look like this ...

 [Column(Storage="_Size", DbType="NVarChar(100)")] public string Size { get { return this._Size; } set { if ((this._Size != value)) { this._Size = value; } } } 

Any ideas on why this is happening and how it will affect my application?

+4
source share
4 answers

Make sure your table has a primary key.

+14
source

Make sure you do not set ObjectTrackingEnabled = false; or that you did not disable it on the surface of the constructor.

+5
source

Adding a primary key will solve the problem.

+1
source

Did you change something in the designer after drag and drop? IIRC, there is a monitored property or some.

0
source

Source: https://habr.com/ru/post/1309703/


All Articles