I have this task in C# with which i want to call a stored procedure in MySql using dapper.
public async Task<List<StatItemListViewModel>> GetTable()
{
using (MySqlConnection connection = new MySqlConnection(Helper.CnnVal("SampleDB")))
{
var results =await connection.QueryAsync<List<StatItemListViewModel>>("Call MainResult_Statistic(@sDate, @eDate)", new { sDate = "2018-11-01", eDate = "2018-11-30" });
return results.FirstOrDefault();
}
}
The problem is that it doesn't return anything.
Can someone help me please?
I solved the issue like this:
public async Task<IEnumerable<StatItemListViewModel>> GetTable(string sDate, string eDate)
{
using (MySqlConnection connection = new MySqlConnection(Helper.CnnVal("SampleDB")))
{
var results = await connection.QueryAsync<StatItemListViewModel>("Call MainResult_Statistic(@sDate, @eDate)",
new { sDate, eDate });
return results.ToList();
}
}
The problem was that I could not convert generic.Ienumerable to generic.List.