title: Unable to cast object of type 'System.Data.SqlClient.SqlDataReader' to type 'System.Collections.Generic.IEnumerable'
body: <p>I've been trying to understand why it's giving me this error because I'm not using SqlDataReader, I get that I'm using SQL Server and the Interface is returning the specific type but still I'm telling .NET to use IDataReader instead.</p>
  
  <p>Here's the code:</p>
  
  <pre><code>    public DataSet ExecuteSelectProcedure(string procedure, List&lt;Parameter&gt; parameters)
      {
          conexion.Open();
  
          try
          {
              IDbCommand command = conexion.CreateCommand();
              command.CommandType = CommandType.StoredProcedure;
              command.Connection = conexion;
              command.CommandText = procedure;
  
              foreach (var parameter in parameters)
              {
                  IDbDataParameter dataParameter = command.CreateParameter();
                  dataParameter.Direction = (System.Data.ParameterDirection) parameter.Direction;
                  dataParameter.Value = parameter.Value;
                  dataParameter.ParameterName = parameter.Name;
                  dataParameter.DbType = (DbType) parameter.Type;
                  command.Parameters.Add(dataParameter);
              }
  
  
              IDataReader result = command.ExecuteReader();
              DataSet dataSet = new DataSet();
              foreach (var table in (IEnumerable&lt;IDataReader&gt;) result)
              {
                  DataTable dataTable = new DataTable();
                  dataTable.Load(table);
                  dataSet.Tables.Add(dataTable);
              }
  
              result.Close();
  
              return dataSet;
          }
          finally
          {
              conexion.Close();
          }
  </code></pre>
  
  <p>The error is when casting IEnumerable on the foreach loop. Thanks in advance... </p>