var query = from s in Stock group s by new {s.Id, s.SupId, s.Text, s.ExternalId} into g select new {g.Key.Id, g.Key.SupId, g.Key.Text, g.Key.ExternalId, Count = g.Count()};