using System.Collections.Generic;
private static DateTimeOffset Now = DateTimeOffset.Now.Date;
public static void Main()
var test1 = new Test{Date = Now, Count = 1};
var test2 = new Test{Date = Now.AddDays(-3), Count = 2};
var test3 = new Test{Date = Now.AddDays(-4), Count = 3};
var list = new SortedSet<Test>();
abd.FillInMissingDays(Now.AddDays(-10),Now.AddDays(10));
Console.WriteLine("Min, {0}",min);
foreach(var l in abd.DateAndValue)
public SortedSet<Test> DateAndValue { get; set; }
public void FillInMissingDays(DateTimeOffset startDate, DateTimeOffset endDate)
var empties = Enumerable.Range(0, endDate.Subtract(startDate).Days)
.Select(i => date.AddDays(i))
.Select(d => new Test{Count = 0, Date = d});
DateAndValue.UnionWith(empties);
public class Test : IComparable<Test>, IEquatable<Test>
public DateTimeOffset Date {get; set;}
public long Count {get; set;}
public int CompareTo(Test other)
return Date.CompareTo(other.Date);
public bool Equals(Test other)
return Date == other.Date && Count == other.Count;
public override string ToString()
return string.Format("{0} {1}", Date, Count);