title: How to aggregate duplicate records and sum value using C#
body: <p>I want to create a list where it holds several agents and the number of calls they make and did it like so:</p>
  
  <pre><code>public class Agent
  {
      public string Agent_ID{ get; set; }
      public string Name { get; set; }
      public int Calls { get; set; }
  
  }
  
  var list = new List&lt;Agent&gt;() // To create a list to hold the data
  { 
      new Agent() { Agent_ID = "TK_J", Name = "James", Calls = 10 },
      new Agent() { Agent_ID = "TK_K", Name = "Kurtis", Calls = 10 },
      new Agent() { Agent_ID = "TK_R", Name = "Rebecca", Calls = 5 },
      new Agent() { Agent_ID = "TK_J", Name = "James", Calls = 10 },
      new Agent() { Agent_ID = "TK_R", Name = "Rebecca", Calls = 5 },
      new Agents(){ Agent_ID = "TK_B", Name = "Bobby", Calls = 10 },
  };
  </code></pre>
  
  <p>As you can see there will be redundant lines of data. So I want to use C# aggregation function such as group by to sum up the similar agent's number of calls. What I was trying was:</p>
  
  <pre><code>list.GroupBy(i =&gt; i.Agent_ID).Select(g =&gt; new 
  { 
  Agent_ID= g.Key, 
  Name = */ How do i bring the name here*/, 
  Calls = g.Sum(i =&gt; i.Calls)});
  </code></pre>
  
  <p>Anyone can help me? Appreciate any help or advice. If there is something wrong teach me how to fix the code. Many thanks!!</p>