Sunday, July 22, 2012

linq group by count


public IEnumerable DrillCountInTrainings()
        {
            var query = from t in context.TRAININGS
                        join td in context.TRAINING_DRILLS on t.training_id equals td.training_id
                        join d in context.DRILLS on td.drill_id equals d.drill_id
                        group t by new { t.name, t.date, t.training_id } into grp
                        orderby grp.Key.date descending
                        select new SuccessReportResultDTO
                        {
                            Name = grp.Key.name,
                            Value = grp.Count(),
                            IdealValue = 0,
                            MeanValue = 0
                        };

            return query;
        }

No comments:

Post a Comment