为什么我在这个LINQ查询中遇到上述错误 - 以及我如何解决它?
System.Nullable<float> totalFreight =
(from cust in db.Customers
join ord in db.Orders on cust.ordID equals ord.OrdID
select ord.Freight).Sum();
注意:订单实体/表中的Freight
属性/列属于float?
类型。我正在EF Core 1.1
使用VS2015
。
更新2 :我将问题隔离如下。此外,我通过将鼠标悬停在ord.Freight
上确认货运确实属于浮动类型来验证:
var totalFreight =
from cust in db.Customers
join ord in db.Orders on cust.ordID equals ord.OrdID
select ord.Freight
var testSum = totalFreight.Sum();
但仍然得到完全相同的错误,这次是在行:var testSum = totalFreight.Sum();