Say I have a list of the following class:
public class Holding
{
public string HoldingId{ get; set; }
public DateTime date { get; set; }
}
There needs to be a holding for each day in a given date range. I need to be able to produce a list of holdings that are missing for the range.
So say I have the following data that I need to check over the range 1 June 2010 - 5 June 2010:
HoldingId Date
1 01-06-2010
1 02-06-2010
1 04-06-2010
2 02-06-2010
2 03-06-2010
2 05-06-2010
3 03-06-2010
For this set of data the missing holdings would be:
HoldingId Date
1 03-06-2010
1 05-06-2010
2 01-06-2010
2 04-06-2010
3 01-06-2010
3 02-06-2010
3 04-06-2010
3 05-06-2010
I have produced the list range of dates using the answer to the following question: Find missing dates for a given range.
I can't quite get my head around how to go forward from here...I assume I'll need to group by HoldingId to produce an array of dates and then do range.Except(holdings.dates) or something to that effect.
Does anyone have a nice solution to this problem using Linq?