How to groupBy a list and map the result to another list
<p>I have the following piece of code:</p>

<pre><code> public List&lt;myTask&gt; MyTask { get; set; }


 public class myTask
{
    public List&lt;int&gt; ID { get; set; }
    public List&lt;DateTime&gt; Date { get; set; }
    public Decimal Total { get; set; }
 }
 List&lt;myTask&gt; tempTask = new List&lt;myTask&gt;();
 MyTask = new List&lt;myTask&gt;();
</code></pre>

<p>I want to do something as follows but having the error message:</p>

<pre><code>MyTask = tempTask.GroupBy(x =&gt; x.Date);
</code></pre>

<blockquote>
  <p>Error 1   Cannot implicitly convert type
  'System.Collections.Generic.IEnumerable,MvcUI.Models.MyTask>>'
  to 'System.Collections.Generic.List'. An explicit
  conversion exists (are you missing a cast?)</p>
</blockquote>

<hr>

<p>Edited Code:</p>

<p>I have tried to add the code:  </p>

<pre><code>var newtempTask = tempTask.GroupBy(x =&gt; x.Date, (Date, values) =&gt;


 new
                    {
                        ID = values.Select(x =&gt; x.ID).ToList(),
                        Date = values.Select(x =&gt; x.Date).ToList(), Total=values.Select(x =&gt; x.Date).ToList() 
                                                                          }); and then 
        foreach (var newitem in newtempTask)
        {
            MyTask.Add(new MyTask
                           {
                               ID = newitem.ID,
                               Date= newitem.Date,Total = newitem.Total
                           });}
</code></pre>

<blockquote>
  <p>I have tried to add the code, please see the above edited code. I am having the error message, Error 7 Cannot implicitly convert type 'System.Collections.Generic.List>' to 'System.Collections.Generic.List'</p>
</blockquote>
