需要按日期范围对多维数据集进行切片。将数据放入多维数据集后,如何传递开始/结束日期以限制切片?
//define full data set
var allRows = (from c in newContext.MCrmOpportunity
orderby c.CloseDate
select c)
.ToList();
//define cube pivot
var cubeData = new PivotData(
new[] { "CloseDate" },
new SumAggregatorFactory("Amount"),
true);
//process data into cube structure
cubeData.ProcessData(allRows.AsEnumerable(), new ObjectMember().GetValue);
var sq = new SliceQuery(cubeData).Where ???????????
var sc = sq.Execute();
return sc;
答案 0 :(得分:0)
为此,请使用此SliceQuery.Where(string dimension, Func predicate)重载:
DateTime startDt; // range start
DateTime endDt; // range end
var sq = new SliceQuery(cubeData).Where("CloseDate",
d => (DateTime)d >= startDt && (DateTime)d <= endDt );
(我假设'CloseDate'维度类型为DateTime;如果没有相应地更改对'd'的处理,则为