Given a datatable of single day dates (dd-mm-yyyy), (shown below on the left).
What's most elegant way to transform this into a collection of ranges, grouping consecutive days for each type (show on the right) ?
We can assume initial data is sorted by TypeID, then Date.
TypeID | Date -> TypeID | Start | End
1 | 01/02/2010 1 | 01/02/2010 | 03/02/2010
1 | 02/02/2010 2 | 03/02/2010 | 04/02/2010
1 | 03/02/2010 2 | 06/02/2010 | 06/02/2010
2 | 03/02/2010
2 | 04/02/2010
2 | 06/02/2010
I'm not particularity up on my LINQ, but I was thinking that might be the way to go?
Any assistance would be greatly appreciated!