Removing nested for loops to hasten API call response time
I think you will see a performance improvement by using GroupBy.

Let's start by calculating the earliest year we're interested in:

startingYear = startingYear ?? DateTime.Now.Year;
var minYear = startingYear - numberOfYears + 1;


Then filter the rows

var deals = db.VDealParticipations
    .Where(deal =&gt; deal.IsPrimaryParticipant &amp;&amp;
                   deal.EffectiveDate.Value.Year &gt;= minYear &amp;&amp;
                   deal.EffectiveDate.Value.Year &lt;= startingYear);
if (brokerID.HasValue)
{
    deals = deals.Where(deal =&gt; deal.BrokerID == brokerID);
}


Finally we group the rows by their year/month.

var dealsPerMonth = deals
    .GroupBy(deal =&gt; new { deal.EffectiveDate.Value.Year, deal.EffectiveDate.Value.Month })
    .Select(g =&gt; new { g.Key.Year, g.Key.Month, Deals = g.Count() });
return new JavaScriptSerializer().Serialize(dealsPerMonth.ToArray());


Note that this does not return months with a deal count of 0.