I use Linq-to-SQL which will generate classes for database tables dragged to its designer. When I drag Product table to designer, Visual Studio will generate like this:
[global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.Products")]
public partial class Product : INotifyPropertyChanging, INotifyPropertyChanged
{
// ...
partial void OnProductIDChanging(int value);
partial void OnProductIDChanged();
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ProductID", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
public int ProductID
{
get
{
return this._ProductID;
}
set
{
if ((this._ProductID != value))
{
this.OnProductIDChanging(value);
this.SendPropertyChanging();
this._ProductID = value;
this.SendPropertyChanged("ProductID");
this.OnProductIDChanged();
}
}
}
//...
}
OnProductIDChanging and OnProductIDChanged are not abstract methods and they are empty but why they don’t give compiling-error. Thanks.
Because they are partial methods.
This article has a very good explanation of partial methods.