I have two IEnumerables
. One contains dates, the other contains data.
DateTime start = DateTime.Today.AddDays(-21);
var dates = Enumerable.Range(0, 21).Select(n => start.AddDays(n)).ToArray();
var data = MyClass.Data.Select(x => new { Date = x.Date, Views = x.Count });
I'm trying to build a table which shows the Views
on a given day. However, data contains some gaps. How do I write a linq query which joins the two sets, and returns the Views
number when present or 0 when there is no matching object in data?
I can do this the old fashioned way with foreach statements but I'd like to know how to do it in Linq.