title: TFS API - slow foreach changeset iteration
body: <p><strong><em>Question Background:</em></strong></p>
  
  <p>I am using the TFS api to query against a large range(1-600+) of files on my TFS server.</p>
  
  <p>From each file I am collecting all of its ChangesetId's which are then collected in a list.</p>
  
  <p><strong><em>The code:</em></strong></p>
  
  <p>This is the code I'm using. It works correctly producing an IEnumerable change set list of all the items for the specified parameters in the QueryHistory method.</p>
  
  <pre><code>        VersionSpec versionFrom = VersionSpec.ParseSingleSpec("C1", null);
  
          VersionSpec versionTo = VersionSpec.Latest;
  
          var changesetList = tfsDevItem.VersionControlServer.QueryHistory(tfsDevItem.ServerItem, VersionSpec.Latest, 0, RecursionType.None, null, versionFrom, versionTo, Int32.MaxValue, true, false);
  
          item.VersionList = new List&lt;int&gt;();
  
          //*****Very slow iteration*****
          foreach (Changeset ChangesetId in changesetList)
          {
              item.VersionList.Add(ChangesetId.ChangesetId);
          }
  </code></pre>
  
  <p><strong><em>The Issue:</em></strong></p>
  
  <p>When looping through each changeset in the chagesetList of the foreach, the time this is taking is <strong><em>incredibly</em></strong> long. For instance 115 files takes <strong><em>1</em></strong> minute to produce a list of each individual files changesetID's.</p>
  
  <p>Can I improve this? If so how?</p>