コード例 #1
0
        public List<NullableFact> Aggregate(List<NullableFact> facts, short parentId)
        {
            var results = new List<NullableFact>();
            var salesComponents = this.hierarchy.GetChildren(parentId).ToList();
            salesComponents.RemoveAll(s => s == parentId);

            foreach (var group in facts
                .Where(f => f.SalesComponentId == null || salesComponents.Contains(f.SalesComponentId.Value))
                .GroupBy(f => new { f.ProductId, f.GeographyId, f.TimeId }))
            {
                var fact = new NullableFact()
                {
                    ProductId = group.Key.ProductId,
                    GeographyId = group.Key.GeographyId,
                    TimeId = group.Key.TimeId,
                    SalesComponentId = parentId,
                    Value = group.Sum(g => g.Value)
                };
                results.Add(fact);
            }
            return results;
        }
コード例 #2
0
 internal float SumChildren(NullableFact fact)
 {
     return this.SumChildren(fact.ProductId, fact.GeographyId, fact.SalesComponentId, fact.TimeId);
 }