1

I am getting the following error when I add the linq grouping.

Error 5 'System.Linq.IGrouping' does not contain a definition for 'Description' and no extension method 'Description' accepting a first argument of type 'System.Linq.IGrouping' could be found (are you missing a using directive or an assembly reference?)

using (var db = new DataContext())
{
     var query = from emp in db.Employees
                               .Where( e=> e.IsDeleted == false && e.DivisionId == divisionId)
                 from rev in db.Reviews
                               .Where( r=> r.EmployeeID == emp.EmployeeId && r.IsDeleted == false && r.ReviewPeriodId == reviewPeriodId)
                               .DefaultIfEmpty()
                 from obj in db.Objectives
                               .Where( o=> o.ReviewId == rev.ReviewId && o.IsDeleted == false)
                               .DefaultIfEmpty()
                 from objps in db.ObjectiveProgressStatusLanguages
                                .Where( s=> s.ObjectiveProgressStatusId == obj.ObjectiveProgressStatusId && s.LanguageId == langueageId)
                                .DefaultIfEmpty()
                 group objps by new {objps.Description, objps.StatusId into opsgroup

                 select new
                 { 
                     Status = opsgroup.Description, 
                     StatusId = opsgroup.StatusId,
                     Count = opsgroup.Count()  
                 };
    return query.CopyToDataTable();
ekad
  • 14,436
  • 26
  • 44
  • 46
Dwight T
  • 1,457
  • 2
  • 11
  • 20

1 Answers1

1

Those fields should be part of the Key. Try changing it to:

  select new {
        Status = opsgroup.Key.Description,
        StatusId = opsgroup.Key.StatusId,
        Count = opsgroup.Count()
  }
tvanfosson
  • 524,688
  • 99
  • 697
  • 795