or
public class CrosstabClassificationModel { public class ApproachModel { public ApproachModel(List<int> lengthGroups) { Lengths = new List<LengthModel>(); int prev = 0; foreach(int i in lengthGroups) { Lengths.Add(new LengthModel() { Min = prev, Max = i }); prev = i + 1; } } public string Name { get; set; } public ApproachTypes ApproachType { get; set; } public List<LengthModel> Lengths { get; private set; } public void Add(int length, DateTime time) { foreach(var l in Lengths) { if(length.IsBetween(l.Min, l.Max)) { l.Add(time); break; } } } public override string ToString() { return Name; } } public class LengthModel { public LengthModel() { Events = new List<EventModel>(); } public string Title { get { if(Max == int.MaxValue) return string.Format("{0} and greater", Min); else return string.Format("{0} - {1}'", Min, Max); } } internal int Min { get; set; } internal int Max { get; set; } public List<EventModel> Events { get; private set; } internal void Add(DateTime time) { var @event = Events.FirstOrDefault(x => x.Time == time); if(@event == null) { @event = new EventModel() { Count = 0, Time = time }; Events.Add(@event); } @event.Count++; } public override string ToString() { return Title; } } public class EventModel { public DateTime Time { get; set; } public int Count { get; set; } public override string ToString() { return Time.ToShortTimeString() + " Total: " + Count.ToString(); } } public CrosstabClassificationModel() { Approaches = new List<ApproachModel>(); } public DateTime Date { get; set; } public List<ApproachModel> Approaches { get; private set; } public ApproachModel this[string Name] { get { return Approaches.FirstOrDefault(x => x.Name == Name); } } public override string ToString() { return Date.ToShortDateString(); } }private void table1_NeedDataSource_1(object sender, EventArgs e){ var objectDataSource = new ObjectDataSource(); objectDataSource.DataSource = ((BestFitStepDetailsReportView)this.DataSource).StepDetailsTable; (sender as Processing.Table).DataSource = objectDataSource;}