public static IEnumerable<TimeInterval> getTimeIntervals(StoredProcedures proc) { var periods = proc.getInterval(IntType.time, () => Intervals.TimeDefault(), cfg => cfg.Periods); var min = periods.First().From; var max = periods.Last().From; foreach (var r in Enumerable.Range(0, 50/*let*/).SelectMany(y => Enumerable.Range(0, 12).Select(m => Admin.Interval.MonthCode(m + 1, y + 2013))).Where(mc => mc >= min && mc <= max)) { yield return new TimeInterval() { period = periods.Last(p => r >= p.From), monthCode = r, }; } }