title: Convert List<string> to a stream
body: <p>The problem I have is that I have a CSV file full of records, that currently is being mapped to a strongly typed collection via the open source <code>CsvHelper.CsvReader.GetRecords&lt;T&gt;</code> method. It gets passed a GZIP stream which is built on a <code>FileStream</code> so is reading the stream from disk.</p>
  
  <p>My suspicion is that the <code>CsvHelper</code> class when used with a <code>FileStream</code> is not very efficient as this load takes a long time. I want to try and load the raw file efficiently first just into memory, and then do the strong type mapping afterwards.</p>
  
  <p>Unfortunately, the mapping class <code>CsvHelper.CsvReader.GetRecords&lt;T&gt;</code> accepts only a stream. I have managed to load the raw data into a <code>List&lt;string&gt;</code> very fast, however I now cannot figure out how to "streamify" this to pass to the mapper. Is this something I can do or is there another solution?</p>
  
  <p>My code so far is</p>
  
  <pre><code>var fileStream = ...
  var gzipStream = new GZipStream(fileStream, CompressionMode.Decompress);
  var entries = new List&lt;string&gt;();
  using (var unzip = new StreamReader(gzipStream))
      while(!unzip.EndOfStream)
           entries.Add(unzip.ReadLine());
  
  Parse(??);
  
          public IReadOnlyCollection&lt;TRow&gt; Parse(Stream stream)
          {
              Func&lt;Stream&gt; streamFactory = () =&gt; stream;
              var results = ParseCsvWithConfig &lt;TRow&gt;(streamFactory, _configuration).AsReadOnly();
         }
  
   public static IEnumerable&lt;T&gt; ParseCsvWithConfig&lt;T&gt;(Func&lt;Stream&gt; streamFactory, CsvConfiguration configuration)
          {
              using (var stream = streamFactory())
              {
                  var streamReader = new StreamReader(stream);
                  using (var csvReader = new CsvReader(streamReader, configuration ?? new CsvConfiguration()))
                  {
                      return csvReader.GetRecords&lt;T&gt;().ToList();
                  }
              }
          }
  </code></pre>