title: Convert DataTable to IEnumerable<T>
body: <p>I am trying to convert a DataTable to an IEnumerable. Where T is a custom type I created. I know I can do it by creating a <code>List&lt;T&gt;</code> but I was thinking if there is a slicker way to do it using IEnumerable. Here is what I have now:</p>
  <pre><code>private IEnumerable&lt;TankReading&gt; ConvertToTankReadings(DataTable dataTable)
  {
      var tankReadings = new List&lt;TankReading&gt;();
      foreach (DataRow row in dataTable.Rows)
      {
          var tankReading = 
                new TankReading
                {
                    TankReadingsID = Convert.ToInt32(row[&quot;TRReadingsID&quot;]),
                    TankID = Convert.ToInt32(row[&quot;TankID&quot;]),
                    ReadingDateTime = Convert.ToDateTime(row[&quot;ReadingDateTime&quot;]),
                    ReadingFeet = Convert.ToInt32(row[&quot;ReadingFeet&quot;]),
                    ReadingInches = Convert.ToInt32(row[&quot;ReadingInches&quot;]),
                    MaterialNumber = row[&quot;MaterialNumber&quot;].ToString(),
                    EnteredBy = row[&quot;EnteredBy&quot;].ToString(),
                    ReadingPounds = Convert.ToDecimal(row[&quot;ReadingPounds&quot;]),
                    MaterialID = Convert.ToInt32(row[&quot;MaterialID&quot;]),
                    Submitted = Convert.ToBoolean(row[&quot;Submitted&quot;]),
                };
  
          tankReadings.Add(tankReading);
      }
      return tankReadings.AsEnumerable();
  }
  </code></pre>
  <p>The key part being I am creating a <code>List&lt;T&gt;</code> then returning it using <code>AsEnumerable()</code>.</p>