Can I use an anonymous type in this situation?
<p>I have this code</p>

<pre><code>   // was before var groupTransactions;
   IEnumerable&lt;IGrouping&lt;TransactionsGroupedByMonthYear, TransactionDto&gt;&gt; groupTransactions = null;

DollarCapPeriod dollarCapPeriod = (DollarCapPeriod)Enum.Parse(typeof(DollarCapPeriod), reward.DollarCapPeriod);
switch (dollarCapPeriod)
{
    case DollarCapPeriod.Monthly:
        groupTransactions = filterdTransactions.GroupBy(x =&gt; new { x.TransactionDate.Month, x.TransactionDate.Year });
        break;
    case DollarCapPeriod.Yearly:
  groupTransactions = filterdTransactions.GroupBy(x =&gt; new TransactionsGroupedByMonthYear { Month = 0, Year = x.TransactionDate.Year });
        break;
    default:
        break;
}
</code></pre>

<p>I want to do something like that but it wants the type initialized. So I am wondering is there away around this or do I have to make some sort of concrete type? If so how do I do it again with groupBy?</p>

<p>Sample Data</p>

<pre><code>1/14/2012,5,Gas
1/15/2012,5,Gas
1/16/2012,5,Gas
1/17/2012,5,Gas
</code></pre>

<p><strong>Edit</strong></p>

<p>Currently I am trying to do now use a concrete backing but I need to filter by 2 different ways. Sometimes I need only the "Year" and some times I need "Month" and "Year"</p>

<p>I don't know how to do this. They both need to go in the same variable so they need to be the same type.</p>
