Я получаю следующую ошибкуОшибка Преобразование Datatable в IEnumerable
Ошибка: - Не может неявно преобразовать тип 'System.Data.EnumerableRowCollection' в 'System.Collections.Generic.IEnumerable'. Явное преобразование существует (вы отсутствует бросок?) C: \ Users \ e19206 \ Documents \ Visual Studio 2010 \ Projects \ TerroristMVC \ TerroristBAL \ Models \ Landingbal.cs 51 20 TerroristBAL
Здесь мой код
public IEnumerable<Landing> getReportSummary()
{
DataTable dtRepSummary = new DataTable();
try
{
procname = "TDS_QUERY.GET_REP_SUMMARY";
OracleParameter[] oraParam = new OracleParameter[1];
oraParam[0] = new OracleParameter("TDS_RECORDSET", OracleDbType.RefCursor);
oraParam[0].Direction = ParameterDirection.Output;
connection = new OracleConnection(SqlHelper.GetConnection());
DataSet ds = SqlHelper.ExecuteDataset(connection, CommandType.StoredProcedure, procname, oraParam);
dtRepSummary = ds.Tables[0];
}
catch (Exception ex)
{
string errormessage = "Method name:- " + MethodBase.GetCurrentMethod().Name + " | Description: " + ex.Message + " " + ex.InnerException;
log.Error(errormessage);
}
return dtRepSummary.AsEnumerable();
}
Вот моя посадка класс Модель
public class Landing
{
#region properties
public string Reportid { get; set; }
public string Reportdate { get; set; }
public string Fromdate { get; set; }
public string Todate { get; set; }
public string Executed { get; set; }
public string Userid { get; set; }
public string Recadddate { get; set; }
#endregion
}
Примечание это также требует сборки System.Data.DataSetExtensions.dll ссылаться, чтобы иметь возможность использовать AsEnumerable и Field (которые входят в класс DataTableExtensions) –
@SimonMourier - Да, OP уже использует этот cz, в настоящее время он возвращает 'dtRepSummary.AsEnumerable()'. –
Я так думаю, но неясно, читал вопрос, его теги или ответ –