title: Merge items in list with the same key/property
body: <p>This shouldn't be very hard to do but I'm struggling to find out the correct way to do this.</p>
  
  <p>I have two lists that have the same properties. What I would like to do is merge these two lists together and combine/merge the individual items in the lists that have the same key/property.</p>
  
  <p>Here is my <code>ViewModel</code>:</p>
  
  <pre><code>public class GradeViewModel {
      public int GradeId { get; set; }
      public string Name { get; set; }
      public int Total { get; set; }
  }
  </code></pre>
  
  <p>And here I am populating my lists:</p>
  
  <pre><code>var buyPostGrades = Mapper.Map&lt;IEnumerable&lt;BuyPostGrade&gt;, IEnumerable&lt;GradeViewModel&gt;&gt;(_reportService.GetBuyPostGrades());
  var sellPostGrades = Mapper.Map&lt;IEnumerable&lt;SellPostGrade&gt;, IEnumerable&lt;GradeViewModel&gt;&gt;(_reportService.GetSellPostGrades());
  </code></pre>
  
  <p>Now what I would like to do is combine the two lists together into one and if there are any items between the lists that share the same <code>GradeId</code> then I want to merge them into just one item.</p>
  
  <p>So, for example, if I had an item in my <code>buyPostGrades</code> list that looked like the following:</p>
  
  <pre><code>GradeId = 6,
  Name = "TestGrade",
  Total = 4
  </code></pre>
  
  <p>and then I had an item in my <code>sellPostGrades</code> list that looked like the following:</p>
  
  <pre><code>GradeId = 6,
  Name = "TestGrade",
  Total = 10
  </code></pre>
  
  <p>then I would like to merge those two items into one that would look like:</p>
  
  <pre><code>GradeId = 6,
  Name = "TestGrade",
  Total = 14
  </code></pre>
  
  <p>I'm sure there in some <code>Linq</code> that I can use to do this but I'm still new to it and am not sure which way would be best.</p>