title: L2S aggregate binding pain
body: <p>I have a fairly simple model:</p>
  
  <pre><code>public class Delivery
  {
      public int DeliveryId { get; set; }
      public int OverId { get; set; }
      public int Ball { get; set; }
      public int Runs { get; set; }
  
      public Player Player { get; set; }
  }
  </code></pre>
  
  <p>All I want to do is have my collection of Delivery objects grouped by Player so that I can then perform some stats calculations on the results in my MVC3 view.</p>
  
  <p>I'm almost there, but between the L2S query and my model binding declaration, I just can't get the two to marry up. </p>
  
  <p>Doing it this way almost works:</p>
  
  <pre><code>var batting = from d in deliveries
                where d.Over.IsBatting == true
                group d by d.Player into player
                select player;
  
  return View(batting);
  </code></pre>
  
  <p>But the view bindings are a mess.
  Bit of help?</p>
  
  <p>EDIT:
  Here's my view:</p>
  
  <pre><code>@model IEnumerable&lt;IGrouping&lt;Cricket.Models.Player, Cricket.Models.Delivery&gt;&gt;
  
  @{
      ViewBag.Title = "Batting";
  }
  
  &lt;h2&gt;Batting&lt;/h2&gt;
  
  &lt;p&gt;
      @Html.ActionLink("Create New", "Create")
  &lt;/p&gt;
  &lt;table&gt;
      &lt;tr&gt;
          &lt;th&gt;&lt;/th&gt;
          &lt;th&gt;
              OverId
          &lt;/th&gt;
          &lt;th&gt;
              Ball
          &lt;/th&gt;
          &lt;th&gt;
              Runs
          &lt;/th&gt;
      &lt;/tr&gt;
  
  @foreach (var Item in Model) {
      &lt;tr&gt;
          &lt;td&gt;
  @*            @Html.ActionLink("Edit", "Edit", new { id=item.DeliveryId }) |
              @Html.ActionLink("Details", "Details", new { id=item.DeliveryId }) |
              @Html.ActionLink("Delete", "Delete", new { id=item.DeliveryId })
  *@        &lt;/td&gt;
          &lt;td&gt;
              @Item.Key
          &lt;/td&gt;
          &lt;td&gt;
              @*item.Ball *@
          &lt;/td&gt;
          &lt;td&gt;
              @Item.Sum(x =&gt; x.Runs)
          &lt;/td&gt;
      &lt;/tr&gt;
  }
  
  &lt;/table&gt;
  </code></pre>