title: Exception of type 'System.OutOfMemoryException' was thrown
body: <p>Basically I use Entity Framework to query a huge database. I want to return a string list then log it to a text file.</p>
  
  <pre><code>List&lt;string&gt; logFilePathFileName = new List&lt;string&gt;();
  var query = from c in DBContext.MyTable where condition = something select c;
  foreach (var result in query)
  {
      filePath = result.FilePath;
      fileName = result.FileName;
      string temp = filePath + "." + fileName;
      logFilePathFileName.Add(temp);
      if(logFilePathFileName.Count %1000 ==0)
          Console.WriteLine(temp+"."+logFilePathFileName.Count);
  }
  </code></pre>
  
  <p>However I got an exception when <code>logFilePathFileName.Count=397000</code>.
  The exception is:</p>
  
  <blockquote>
    <p>Exception of type 'System.OutOfMemoryException' was thrown.</p>
    
    <p>A first chance exception of type 'System.OutOfMemoryException'
    occurred in System.Data.Entity.dll</p>
  </blockquote>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>What I want to use a different query say: select top 1000 then add to the list, but I don't know after 1000 then what?</p>