CsvHelper not writing anything to memory stream
<p>I have the following method:</p>

<pre><code>public byte[] WriteCsvWithHeaderToMemory&lt;T&gt;(IEnumerable&lt;T&gt; records) where T : class
{
    using (var memoryStream = new MemoryStream())
    using (var streamWriter = new StreamWriter(memoryStream))
    using (var csvWriter = new CsvWriter(streamWriter))
    {
        csvWriter.WriteRecords&lt;T&gt;(records);

        return memoryStream.ToArray();
    }
}
</code></pre>

<p>Which is being called with a list of objects - eventually from a database, but since something is not working I'm just populating a static collection.  The objects being passed are as follows:</p>

<pre><code>using CsvHelper.Configuration;

namespace Application.Models.ViewModels
{
    public class Model
    {
        [CsvField(Name = "Field 1", Ignore = false)]
        public string Field1 { get; set; }

        [CsvField(Name = "Statistic 1", Ignore = false)]
        public int Stat1{ get; set; }

        [CsvField(Name = "Statistic 2", Ignore = false)]
        public int Stat2{ get; set; }

        [CsvField(Name = "Statistic 3", Ignore = false)]
        public int Stat3{ get; set; }

        [CsvField(Name = "Statistic 4", Ignore = false)]
        public int Stat4{ get; set; }
    }
}
</code></pre>

<p>What I'm trying to do is write a collection to a csv for download in an MVC application.  Every time I try to write to the method though, the MemoryStream is coming back with zero length and nothing being passed to it.  I've used this before, but for some reason it's just not working - I'm somewhat confused.  Can anyone point out to me what I've done wrong here?</p>

<p>Cheers</p>
