0

I am trying to test out NReco.PivotData for in memory cubing. Our existing process is using entity framework and is able to pull the data but I can't find the right way to put it into the cube.

Tried casting the data as a list, an array, enumerable and 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);

The error is on the last line.

Error CS1503 Argument 1: cannot convert from 'System.Collections.Generic.IEnumerable' to 'System.Collections.Generic.IEnumerable System.Collections.Generic.IDictionary>'

Jason
  • 13
  • 3

1 Answers1

0

PivotData.ProcessData method that accepts only one argument expects either IEnumerable<DataRow> or IEnumerable<IDictionary<string, Object>>. To aggregate data from collection of models you need to use ProcessData(IEnumerable data, Func getValue) overload:

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

(assuming that "closeDate", "opportunityName", "amount" are properties of MCrmOpportunity model)

Note that approach when data is aggregated with "ProcessData" method is good only for small number of models; in case of many database records it is much better to perform aggregation on database level (with SQL GROUP BY) and load aggregation results into PivotData class as described here.

Vitaliy Fedorchenko
  • 8,447
  • 3
  • 37
  • 34