0

我正在尝试测试 NReco.PivotData 的内存立方体。我们现有的流程使用实体框架并且能够提取数据,但我找不到将其放入多维数据集的正确方法。

尝试将数据转换为列表、数组、可枚举和 json

var pvtData = new PivotData(
      new[] { "closeDate", "opportunityName" },
      new SumAggregatorFactory("amount"), true);

  var allRows = (from c in newContext.MCrmOpportunity select c).AsEnumerable();

  pvtData.ProcessData(allRows);

错误在最后一行。

错误 CS1503 参数 1:无法从 'System.Collections.Generic.IEnumerable' 转换为 'System.Collections.Generic.IEnumerable System.Collections.Generic.IDictionary>'

4

1 回答 1

0

仅接受一个参数的PivotData.ProcessData 方法IEnumerable<DataRow>需要或IEnumerable<IDictionary<string, Object>>。要从模型集合中聚合数据,您需要使用ProcessData(IEnumerable data, Func getValue)重载:

pvtData.ProcessData(allRows, new ObjectMember().GetValue);

(假设“closeDate”、“opportunityName”、“amount”是 MCrmOpportunity 模型的属性)

请注意,使用“ProcessData”方法聚合数据时的方法仅适用于少量模型;如果有许多数据库记录,最好在数据库级别(使用 SQL GROUP BY)执行聚合并将聚合结果加载到 PivotData 类中,如此处所述

于 2019-08-23T05:40:42.680 回答