Linq Getting Customers group by date and then by their type

var query = _customerRepo.Table
     .GroupBy(c => new {Date = c.Date.Date,  Type = c.TypeOfCustomer})
     .Select(g => new 
                   {
                       Date = g.Key.Date,
                       Type = g.Key.Type, 
                       Count = g.Count
                   }
            )
     .OrderByDescending (r = r.Date);

Leave a Comment