There was a similar question before Grouping records hour by hour or day by day and filling gaps with zero or null and Grouping records hour by hour or day by day and filling gaps with zero or null in mysql but both solutuion use SQL. I would like to resolve this problem with code.
The easiest solution is to run:
var q = from i in XXX.Table
let dt = p.Date
group i by new { y = dt.Year, m = dt.Month, d = dt.Day, h = dt.Hour}
select g;
but I have got a lot of gaps still to fill.