Reputation: 211
I read the doc on Dynamic Linq Core here, where it says
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:
I'm having a hard type following this instruction, so far I tried
.Select("new (Key.Date, Key.t, Sum(cashflow) as Profit, (double)Sum(cashflow) as TestConvertType)");
and
.Select("new (Key.Date, Key.t, Sum(cashflow) as Profit, Sum(cashflow).type(double) as TestConvertType)");
and I got
"'.' or '(' or string literal expected"
I also tried:
.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 worked. Can someone give me an example on how to explicitly convert type in Dynamic Linq?
Upvotes: 0
Views: 1209
Reputation: 211
ok got it.. just use Type(expression)
.Select("new (Key.Date, Key.t, Sum(cashflow) as Profit, Double(Sum(cashflow)) as TestConvertType)");
Upvotes: 0