More Complete WP7 Mango Database Update Walkthrough
September 15, 2011 in Silverlight, Uncategorized, Windows Phone 7
The MSDN documentation gives a walkthrough of how to update a local database application on the Windows Phone over time. The documentation gives quite a bit of detail but seems to miss a likely scenario. So let’s investigate the process step-by-step.
Initial Version
We are creating the first version of our application and decide that we need a User database table with the following columns: Name (primary key), LastAccessedDate
So we create a User class as follows:
[Table]
public class User : INotifyPropertyChanged, INotifyPropertyChanging
{
private string name;
private DateTime? lastAccessed;
[Column(IsPrimaryKey = true, CanBeNull = false, AutoSync = AutoSync.OnInsert)]
public string Name
{
get { return name; }
set
{
NotifyPropertyChanging("Name");
name = value;
NotifyPropertyChanged("Name");
}
}
[Column]
public DateTime? LastAccessed
{
get { return lastAccessed; }
set
{
NotifyPropertyChanging("LastAccessed");
lastAccessed = value;
NotifyPropertyChanged("LastAccessed");
}
}
// Version column aids update performance.
[Column(IsVersion = true)]
private Binary version;
// INotifyPropertyChanged Members
// INotifyPropertyChanging Members
}