views:

23

answers:

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();

Thanks

+1  A: 

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
Thanks, that worked.
Dwight T