title: c# custom group by really slow for large data set
body: <p>When I run the following code where campaigns.Count() is 200,000 this code is really slow.</p>
  
  <pre><code>List&lt;Campaign&gt; listCampaigns = new List&lt;Campaign&gt;();
          foreach (var item in campaigns)
          {
              if (listCampaigns.Where(a =&gt; a.CampaignName == item.CampaignName &amp;&amp; a.Term == item.Term).Count() == 0)
              {
                  //this doesn't exist
                  listCampaigns.Add(item);
              }
              else
              {
                  //this exists already
                  var campaign = listCampaigns.Where(a =&gt; a.CampaignName == item.CampaignName &amp;&amp; a.Term == item.Term).First();
                  campaign.TotalVisits += item.TotalVisits;
                  List&lt;Conversion&gt; listConversions = item.Conversions.ToList();
                  listConversions.AddRange(campaign.Conversions.ToList());
                  campaign.Conversions = listConversions.ToArray();
              }
          }
  </code></pre>
  
  <p>Is there anyway to optimize parts of this code or use another method to speed it up?</p>
  
  <p>Any suggestions are appreciated. Thanks.</p>