What happens is that I have this property:
[Display(Name = "Codigo EAN-UCC", Description = "Codigo EAN-UCC para recaudos por codigo de barras", GroupName = "Tesoreria")]
public string TESORERIA_CODEANUCC { get { return (Get() == null ? "" : (string)Get()); } set { Set(value); OnPropertyChanged(); } }
And then that property I charge with some data from a table called Parametro
but within the requirements I have to first load a Dictionary
that is this:
private Dictionary<string, object> Valores = new Dictionary<string, object>();
and then I can load the Dictionary
by means of the query and a simple foreach:
foreach (var i in vr)
{
Valores.Add(i.Codigo, i.Valor);
}
And then the Dictionary
is loaded so what I have to do is to assign the property to its value according to the key of Dictionary
and I can do it like this:
this.TESORERIA_CODEANUCC = Valores["TESORERIA_CODEANUCC"].ToString();
And it works perfect, but within the requirements there are many parameters and fields to fill, could be dozens, and then I would have to declare all, besides that if a new one is added to the database, I would have to go to the code to add it and then the idea is that the programming is scalable in the future.
So I wanted to do something with the OnPropertyChange()
, I want something more or less that is a loop and in the foreach while adding Dictionary
go assign the value to the property. How could I do it?