我在 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)
问题是它不返回任何东西。
有人能帮助我吗?
我解决了这样的问题:
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。
| 归档时间: |
|
| 查看次数: |
6792 次 |
| 最近记录: |