title: linq: groupby with multiple nullable types
body: <p>I have the following table:</p>
  
  <pre><code>| AppointID | UserID | AppointSet | AppointAttended | AppointCancelled | AppointRescheduled |
  |     1     |   1    |  2/15/2011 |                 |   3/11/2011      |                    |
  |     2     |   1    |  2/17/2011 |                 |                  |    3/11/2011       |
  |     3     |   1    |  3/11/2011 |   3/11/2011     |                  |                    |
  |     4     |   1    |  3/10/2011 |                 |   3/11/2011      |                    
  </code></pre>
  
  <p>|</p>
  
  <p>What I'm trying to do is create the following output that counts the activity by day.</p>
  
  <pre><code>|    Date     |   Set   |   Attended   |   Rescheduled   |   Cancelled   |
  |  3/10/2011  |    1    |              |                 |               |
  |  3/11/2011  |    1    |      1       |       1         |      2        |
  </code></pre>
  
  <p>Note that I've defined the fields AppointAttended, AppointCancelled and AppointRescheduled as nullable because there might not be a date for these.</p>
  
  <p>This is what I have so far and I'm struggling with the groupby because I need to group by multiple columns, and it's a nullable type, and I can't get the .Key to work! In other words, I feel really stuck with this:</p>
  
  <pre><code>var OutputMonthlyActivity = from appnt in MyDC.LeadsAppointments
  where appnt.UserID == TheUserID
  where (appnt.AppointSet.Month == TheDate.Month &amp;&amp; appnt.AppointSet.Year == TheDate.Year) ||
  (appnt.AppointAttended.Value.Month == TheDate.Month &amp;&amp; appnt.AppointAttended.Value.Year == TheDate.Year) ||
  (appnt.AppointRescheduled.Value.Month == TheDate.Month &amp;&amp; appnt.AppointRescheduled.Value.Year == TheDate.Year) ||
  (appnt.AppointCancelled.Value.Month == TheDate.Month &amp;&amp; appnt.AppointCancelled.Value.Year == TheDate.Year)
  group appnt by new { appnt.AppointSet, appnt.AppointRescheduled, appnt.AppointAttended, appnt.AppointCancelled } into daygroups
  where daygroups.Count() &gt; 1
  select new ViewMonthlyActivityModel()
  {
  
  ViewDate = daygroups.Key,
  
  CountTotalSetOnDay = (from c in daygroups
  where c.AppointSet.Date == daygroups.Key
  select c.AppointID).Count(),
  </code></pre>
  
  <p>TheDate is a datetime that's passed in as a parameter and that represents the 1st day of the month that's queried: 3/1/2011 for the month of the March for example.</p>
  
  <p>I get "An anonymous type cannot have multiple properties with the same name" in the groupby statement and the .Key doesn't work so the grouping by day is not working.</p>
  
  <p>If you have any suggestions, that'd be really appreciated.</p>
  
  <p>Thanks.</p>