GroupBy and average a column in Linq
<p>I have this piece of code regarding the bellow table:</p>

<pre><code>Date          Hour    Value (string)
2016-01-01    00:00   10
2016-01-01    00:00   12
2016-01-01    00:00   11
2016-01-01    00:01   10
2016-01-01    00:01   10
2016-01-01    00:01   12
</code></pre>

<p>I would like to group this by date and hour and make an average of value (converting it to double).</p>

<p>I've tried several solutions but no success when it comes to have a result like this:</p>

<pre><code>Date-Hour            Value (string)
2016-01-01 - 00:00   11
2016-01-01 - 00:01   10,6
</code></pre>

<p>I've tried the bellow linq query to get it:</p>

<pre><code>...
var data = (from ent in db.T060_DATA
            where ent.id_indicador == id
            group ent by new { ent.data, ent.hora } into g
            select new { g.Key, List = g.ToList(), Valor = g.Average(val =&gt; double.Parse(val.valor)) }).ToList();
</code></pre>

<p>I want this results to fill a <code>List&lt;ChartData&gt;</code>:</p>

<pre><code>public class ChartData
{
    public string data_hora { get; set; }
    public double valor { get; set; }
}
</code></pre>