The cast to value type 'System.Decimal' failed because the materialized value is null. Eithe
Posted firstcsharp
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了The cast to value type 'System.Decimal' failed because the materialized value is null. Eithe相关的知识,希望对你有一定的参考价值。
CurrentStock = db.BillEntry.Where(b => b.GoodsId == item.GoodsId).Sum(b => (decimal?)b.Qty) ?? 0,
出现这种错误是因为没有获取到数据造成的,可以使用三元判断来操作,注意Sum里的Qty应该可以为空,如果为空则返回0,否则正式返回。
以上是关于The cast to value type 'System.Decimal' failed because the materialized value is null. Eithe的主要内容,如果未能解决你的问题,请参考以下文章
RuntimeError: result type Float can‘t be cast to the desired output type long int
No function matches the given name and argument types. You might need to add explicit type casts
一步真实解决RuntimeError: result type Float can‘t be cast to the desired output type long int
No operator matches the given name and argument type(s). You might need to add explicit type casts报错
Type safety: Unchecked cast from Object to ArrayList
MongooseError: Cast to ObjectID failed for value on reading json for db seed