Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LINQ-to-SQL class doesn't implement INotifyPropertyChanging & INotifyPropertyChanged if pulling from local database

I modified my data source in my LINQ-to-SQL class (by the old delete and drag back in method), and was surprised to see the INotifyPropertyChanging & INotifyPropertyChanged interfaces no longer implemented in the generated classes (MyDb.designer.cs).

The methods for the individual fields went from looking like this...

[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 looking 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 happens and how it will affect my application?

like image 226
Feckmore Avatar asked May 13 '10 20:05

Feckmore


3 Answers

Make sure your table has a primary key.

like image 186
Marek Stój Avatar answered Oct 01 '22 04:10

Marek Stój


Check to make sure you did not set ObjectTrackingEnabled = false; or that you did not turn it off on the designer surface.

like image 21
Adam Avatar answered Oct 01 '22 03:10

Adam


Adding primary key will resolve the problem.

like image 27
Greatran Avatar answered Oct 01 '22 02:10

Greatran