【发布时间】:2012-02-02 18:49:33
【问题描述】:
当我尝试使用 Math.Round(x,0) 或 Math.Round(x) 时,我收到错误 System.Linq.Dynamic.ParseException: No applicable method 'Round' exists in type 'Math'。
当我尝试使用 Convert.ToInt64(x) 时出现异常 Expression of type 'System.Nullable`1[System.Decimal]' cannot be used for parameter of type 'System.Object' of method 'Int64 ToInt64(System.Object)'
当我尝试使用 (long)x 时,出现异常 No property or field 'long' exists in type 'DynamicClass1'。
【问题讨论】:
-
我们能看到引发这些错误的代码吗?
-
你能不能自己制作方法并检查十进制可空的 ABS
-
给出异常的代码行如下所示:query.GroupBy("new(x as FieldName)","it")。我想按此字段分组,但按浮点值分组会给出太多组值,所以我想通过四舍五入来减少组数: query.GroupBy("new(Math.Round(x) as FieldName)" “它”)。
标签: c# linq math dynamic dynamic-linq