2
Problem
I’m starting an application for Windows Phone 7.1, and I’m implementing the database, only I came across a situation that I couldn’t find any example of similar situation to try to solve, and I also couldn’t find anything that would help me in Microsoft documentation.
The situation is as follows:
I have a class
similar to this:
public class Setup : INotifyPropertyChanged, INotifyPropertyChanging
{
private long _id;
private string _descricao;
private IList<long> _tempos;
[Column(IsPrimaryKey = true, IsDbGenerated = true, DbType = "INT NOT NULL Identity", CanBeNull = false, AutoSync = AutoSync.OnInsert)]
public virtual long Id
{
get { return _id; }
set
{
if (value != _id)
{
_id = value;
NotifyPropertyChanged("Id");
}
}
}
[Column]
public virtual string Descricao
{
get { return _descricao; }
set
{
if (value != _descricao)
{
_descricao = value;
NotifyPropertyChanged("Nome");
}
}
}
// como eu faria para mapear corretamente esse campo
[Column]
public virtual IList<long> Tempos
{
get
{
if (_tempos == null)
_tempos = new List<long>();
return _tempos;
}
set
{
if (value != _tempos)
{
NotifyPropertyChanging("");
_tempos = value;
NotifyPropertyChanged("Tempos");
}
}
}
// Version column aids update performance.
[Column(IsVersion = true)]
private Binary _version;
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
public event PropertyChangingEventHandler PropertyChanging;
private void NotifyPropertyChanging(string propertyName)
{
if (PropertyChanging != null)
{
PropertyChanging(this, new PropertyChangingEventArgs(propertyName));
}
}
}
Question
In case, how would I map correctly the field IList<long> Tempos
, since it is not a simple field, it is a list of long
, or would have to create a class
(Time, for example) and treat as a 1 x N relationship? If so, how would it be? If possible with examples.
Like this
Tempo
would be filled?– Leonel Sanches da Silva
With times in minutes that the setups were executed. It’s kind of a setup time history. I don’t know if it’s the best way.
– Fernando Leal