为什么我不能在这里添加.ToList()
?唯一允许的是.ToString()
。
//..
string sqlQuery = "SELECT sum(SellingPrice) as SellingPrice, sum(MarkupPercent) as MarkupPercent, sum(MarkupAmount) as MarkupAmount FROM ProfitMargins WHERE QuoteId in @QuoteId group by multiplier";
{
List<ProfitMargin> profitMargin = (List<ProfitMargin>)await conn.QueryAsync<List<ProfitMargin>>(sqlQuery, new { QuoteId = QuoteIds.ToArray()}) //would like to add .ToList() here;
return profitMargin;
}
//..
更新
我认为问题与conn.queryasync有关(conn是context.Database.Connection.ConnectionString),而不是context.Database.SqlQuery。
ProfitMargin
,而不是List<ProfitMargin>
。 - user47589