title: Calling .ToArray on an Enumerable corrupts the Enumerable
body: <p>I'm not sure if this is specific to ML.NET, but it does happen in the context of it.</p>
  
  <p>I am using ML.NET to classify some images. I realized that it poses a severe difference whether I call <code>.ToArray()</code> on the resulting <code>IEnumerable</code> or not. The former results in all the array elements becoming identical to the last one.</p>
  
  <pre><code>IEnumerable&lt;ImageData&gt; dataCollection = imagePaths.Select(path =&gt; new ImageData(path));
  IDataView targetDataView = _mlContext.Data.LoadFromEnumerable(dataCollection);
  IDataView predictionView = _transformerModel.Transform(targetDataView); 
  return _mlContext.Data.CreateEnumerable&lt;ImagePrediction&gt;(predictionView, true).ToArray();
  </code></pre>
  
  <p>In the example shown above, the resulting predictions will all have their image path set to the last image path in <code>imagePaths</code>.</p>
  
  <p>I don't believe that this is intended behaviour. What causes this and how can I safely prevent this? For the moment I decided to just not call <code>.ToArray()</code>, but I'd like to know more about this issue.</p>