Initial conditions:
DateTime moment
string key
double value
somewhere across the code i want to
Add("2010.08.09 12:55:34", "px_ValX", 10);
Add("2010.08.09 12:55:35", "px_ValX", 1);
Add("2010.08.09 12:55:35", "px_ValY", 12);
Add("2010.08.09 12:55:35", "px_ValZ", 100);
Add("2010.08.09 12:55:38", "px_ValZ", 5);
and then i want to get table from that data array
DataTable ToTable()
which produces
date|px_valX|px_ValY|px_ValZ
"2010.08.09 12:55:34"|10|0|0
"2010.08.09 12:55:35"|1|12|100
"2010.08.09 12:55:38"|0|0|5
Also it would be awesome if i could do fast
double Get(DateTime moment, string key)
and
DataTable Get(string key)
which produces the following table
data|value
"2010.08.09 12:55:34"|10
It's rather SQL task, but i need in-memory data structure. I plan to use C# DataTable class and its Select method, but i think there is more fast and convenient way.
Right on this moment i use the following class in my app
[Serializable]
public class CalcItem
{
public CalcItem()
{
Additional = new Dictionary<string, double>();
}
public Dictionary<string, double> Additional { get; set; }
public DateTime Date { get; set; }
}
and in CalcItemManager
public List<CalcItem> CalcItems { get; set; }
To add data i do
var clc = new CalcItem();
clc.Additional.Add("px_ValX", 10);
_dataManager.CalcItems.Add(clc);