title: i need fast and convenient way to organize table data in-memory
body: <p>Initial conditions:</p>
  
  <pre><code>DateTime moment
  
  string key
  
  double value
  </code></pre>
  
  <p>somewhere across the code i want to </p>
  
  <pre><code>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); 
  </code></pre>
  
  <p>and then i want to get table from that data array</p>
  
  <pre><code>DataTable ToTable()
  </code></pre>
  
  <p>which produces</p>
  
  <pre><code>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
  </code></pre>
  
  <p>Also it would be awesome if i could do fast</p>
  
  <pre><code>double Get(DateTime moment, string key)
  </code></pre>
  
  <p>and</p>
  
  <pre><code>DataTable Get(string key) 
  </code></pre>
  
  <p>which produces the following table</p>
  
  <pre><code>data|value
  "2010.08.09 12:55:34"|10
  </code></pre>
  
  <p>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.</p>
  
  <p>Right on this moment i use the following class in my app</p>
  
  <pre><code>[Serializable]
  public class CalcItem
  {
      public CalcItem()
      {
          Additional = new Dictionary&lt;string, double&gt;();
      }
      public Dictionary&lt;string, double&gt; Additional { get; set; }
  
      public DateTime Date { get; set; }
  }
  </code></pre>
  
  <p>and in CalcItemManager</p>
  
  <pre><code>public List&lt;CalcItem&gt; CalcItems { get; set; }
  </code></pre>
  
  <p>To add data i do</p>
  
  <pre><code>var clc = new CalcItem();
  clc.Additional.Add("px_ValX", 10);
  _dataManager.CalcItems.Add(clc);
  </code></pre>