I wonder if you should do this "long" way ...
dc.MyTable .GroupBy(r => new { Name = r.UserName, Year = r.SomeDateTime.Year, Month = r.SomeDateTime.Month }) .Select(r => new { Name = r.UserName, Year = r.Year, Month = r.Month, Count = r.Count() }) .OrderBy(r => r.Year) .ThenBy(r => r.Month) .ThenBy(r => r.Name);
If you need a string format, do it later in the user interface. Either by restoring DateTime , etc., Or using CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(...) .
source share