title: outer join two anonymous types and reference a single property in the join query?
body: <p>Given:</p>
  
  <pre><code>var memberships = context.Memberships.OrderBy("it.CreateDate").ToList();
  
              var monthlyCounts = from m in memberships
                                       where m.CreateDate &gt;= today.AddDays(-365) &amp;&amp; m.CreateDate &lt;= today
                                       group m by m.CreateDate.Month
                                           into g
                                           select new
                                           {
                                               MemberCount = g.Count(m =&gt; m.UserId != null),
                                               MembershipDate = g.Key,
                                           };
  </code></pre>
  
  <p>I'm trying to join that with a list of months:</p>
  
  <pre><code> var months = Enumerable.Range(0, (d1.Year - d0.Year) * 12 + (d1.Month - d0.Month + 1))
                  .Select(m =&gt; new DateTime(d0.Year, d0.Month, 1).AddMonths(m).Month);
  </code></pre>
  
  <p>This is what I came up with:</p>
  
  <pre><code>var cumlativeCounts = from d in months
                                    join m in monthlyCounts on d equals m.MembershipDate into ms
                                    from m in ms.DefaultIfEmpty()
                                    select new
                                               {
                                                   Month = d,
                                                   Count = m.MemberCount
                                               };
  </code></pre>
  
  <p>Problem is I get an 'Object Reference not Set to an Instance of an Object' Exception, presumably on m.MemberCount</p>
  
  <p>When I just use Count = m then I get all the properties from the monthlyCounts anonymous type, which is not exactly what I want. </p>
  
  <p>Is there another way to outer join two anonymous types and reference a single property in the join query? </p>
  
  <p>Thanks in advance.</p>