Example #1
0
        public bool EqualsExpression(T obj, PivotHeaderCell <T> current)
        {
            var col   = current.Column;
            var param = current.LeadObject;

            return(col.ValueGetter(obj) == col.ValueGetter(param));
        }
Example #2
0
        /// <summary>
        /// Get Measure Value
        /// </summary>
        /// <param name="row"></param>
        /// <param name="col"></param>
        /// <param name="measure"></param>
        /// <returns></returns>
        public decimal GetValue(PivotHeaderCell <T> row, PivotHeaderCell <T> col, PivotMeasure <T> measure)
        {
            var query     = __source.AsQueryable();
            var paramCell = new List <PivotHeaderCell <T> >();

            if (row != null)
            {
                var current = row;
                while (current != null)
                {
                    paramCell.Add(current);
                    current = current.Parent;
                }
            }
            if (col != null)
            {
                var current = col;
                while (current != null)
                {
                    paramCell.Add(current);
                    current = current.Parent;
                }
            }
            foreach (var item in paramCell)
            {
                query = query.Where(t => item.Column.EqualsExpression(t, item.LeadObject));
            }
            return(measure.aggregate(query.Select(t => measure.ValueGetter(t))));
        }
Example #3
0
        /// <summary>
        /// Build Header Cell recursively
        /// </summary>
        /// <param name="source"></param>
        /// <param name="column"></param>
        /// <param name="parent"></param>
        private void BuildHeaderCells(IEnumerable <T> source, PivotColumn <T> column, PivotHeaderCell <T> parent = null)
        {
            var list = column.Order == PivotOrder.Ascending
                            ? source.GroupBy(column.KeySelector).OrderBy(grp => grp.Key)
                            : source.GroupBy(column.KeySelector).OrderByDescending(grp => grp.Key);

            foreach (var group in list)
            {
                var cell = new PivotHeaderCell <T>(group.First(), column);
                column.Cells.Add(cell);
                if (parent != null)
                {
                    parent.__Children.Add(cell);
                }
                cell.Parent = parent;
                if (column.LowerColumn != null)
                {
                    BuildHeaderCells(group, column.LowerColumn, cell);
                }
            }
        }
Example #4
0
 /// <summary>
 /// Get Measure Value
 /// </summary>
 /// <param name="row"></param>
 /// <param name="col"></param>
 /// <param name="measure"></param>
 /// <returns></returns>
 public decimal this[PivotHeaderCell <T> row, PivotHeaderCell <T> col, PivotMeasure <T> measure] {
     get {
         return(GetValue(row, col, measure));
     }
 }