我尝试更改方法以使其异步并使用Dapper 这是存储库类中的当前方法:
SELECT * FROM F(val)
我试图让它像这样异步:
...
public class ClientsRepository : BaseRepository
{
public ClientsRepository(string connectionString): base (connectionString){ }
...
public List<ClientSummaryModel> GetClientSummaryCredit(string id)
{
try
{
connection();
con.Open();
con.ChangeDatabase("PAQA");
IList<ClientSummaryModel> SummaryClientList= SqlMapper.Query<ClientSummaryModel>(con, "dbo.SP_GET_CLIENT_SUMMARY '" + id + "','0','CREDIT'", CommandType.StoredProcedure).ToList();
return SummaryClientList.ToList();
}
catch (Exception ex)
{
throw ex;
}
finally
{
con.Close();
}
}
不幸的是,我收到以下错误:
无法隐式转换类型 &#39; System.Collections.Generic.IEnumerable&#39; 至 &#39; System.Collections.Generic.IList&#39 ;. 存在显式转换(您是否错过了演员?)
我需要改变以像第一种方法一样返回?
其他信息: 这是我的子类化的存储库基类:
public async Task<List<ClientSummaryModel>> GetClientSummaryCredit(string id)
{
return await WithConnection(async c =>
{
c.ChangeDatabase("PAQA");
IList<ClientSummaryModel> SummaryClientList= await c.QueryAsync<ClientSummaryModel>("dbo.SP_GET_CLIENT_SUMMARY '" + id + "','0','CREDIT'", CommandType.StoredProcedure).ToList();
return SummaryClientList.ToList();
});
}