如何在 Dynamic Linq Core 中显式转换类型?

How to explicitly convert type in Dynamic Linq Core?

我阅读了关于 Dynamic Linq Core here 的文档,上面写着

The expression language allows explicit conversions using the syntax type (expr), where type is a type name optionally followed by ? and expr is an expression. This syntax may be used to perform the following conversions:

按照此说明,我很难打字,到目前为止我已经尝试过了

.Select("new (Key.Date, Key.t, Sum(cashflow) as Profit, (double)Sum(cashflow) as TestConvertType)");

.Select("new (Key.Date, Key.t, Sum(cashflow) as Profit, Sum(cashflow).type(double) as TestConvertType)");

我得到了

"'.' or '(' or string literal expected"

我也试过:

.Select("new (Key.Date, Key.t, Sum(cashflow) as Profit, Convert.ToDouble(Sum(cashflow)) as TestConvertType)");

"LINQ to Entities does not recognize the method 'System.Decimal ToDecimal(Double)' method, and this method cannot be translated into a store expression."

None 有效。有人可以给我一个关于如何在 Dynamic Linq 中显式转换类型的示例吗?

好的,知道了..只需使用 Type(expression)

.Select("new (Key.Date, Key.t, Sum(cashflow) as Profit, Double(Sum(cashflow)) as TestConvertType)");