小编Nov*_*ice的帖子

Linq SUM值错误

public async Task<WalletTrans> getCredits(int id) 
{
    var credit = await _context.walletTrans.ToAsyncEnumerable().Where(r => r.Id == id).Sum(s => s.quantity);
    return credit;
}
Run Code Online (Sandbox Code Playgroud)

我上面的代码使用的是C#.net核心,据说可以返回表中字段的总和.

但我有这个错误.

"无法将类型'decimal'隐式转换为'ProjectName.Models.ModelName'[ProjectName]"

c# linq .net-core

0
推荐指数
1
解决办法
97
查看次数

标签 统计

.net-core ×1

c# ×1

linq ×1