Dapper QueryAsync,返回一个列表

Erj*_*jon 0 c# mysql dapper

我在 C# 中有这个任务,我想使用 dapper 在 MySql 中调用存储过程。

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();
        }            
    }
Run Code Online (Sandbox Code Playgroud)

问题是它不返回任何东西。

有人能帮助我吗?

Erj*_*jon 6

我解决了这样的问题:

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();
    }                  
}
Run Code Online (Sandbox Code Playgroud)

问题是我无法将 generic.Ienumerable 转换为 generic.List。