Local Database Sample Model
[Table] public class AddTableNameHere : INotifyPropertyChanged, INotifyPropertyChanging { // // TODO: Add columns and associations, as applicable, here. // // Version column aids update performance. [Column(IsVersion = true)] private Binary _version; public event PropertyChangedEventHandler PropertyChanged; // Used to notify that a property changed private void NotifyPropertyChanged(string propertyName) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } public event PropertyChangingEventHandler PropertyChanging; // Used to notify that a property is about to change private void NotifyPropertyChanging(string propertyName) { if (PropertyChanging != null) { PropertyChanging(this, new PropertyChangingEventArgs(propertyName)); } } }
This is a basic template for an entity, a class that represents a local database table. The following code features that we recommend most entities have in common:
-
The [table] attribute specifies that the class will represent a database table.
-
The INotifyPropertyChanged interface is used for change tracking.
-
The INotifyPropertyChanging interface helps limit memory consumption related to change tracking.
-
The Binary version column, with the [Column(IsVersion = true)] attribute, significantly improves table update performance.