title: The type arguments for method cannot be inferred from the usage. Try specifying the type arguments explicitly
body: <p>I've got a linq query that I am returning a <code>Dictionary&lt;int, string&gt;</code> from.  I've got an overloaded  caching method, that I have created that will take a <code>Dictionary&lt;T,T&gt;</code> item as one of the arguments.  I've got some other methods in this class that take <code>List&lt;T&gt;</code> and <code>T[]</code> without issue.  But this one method, refuses to compile with the error message of the thread subject.</p>
  
  <p>This is my code for the caching class:</p>
  
  <pre><code>public static bool AddItemToCache&lt;T&gt;(string key, Dictionary&lt;T, T&gt; cacheItem, DateTime dt)
  {
      if (!IsCached(key))
      {
          System.Web.HttpRuntime.Cache.Insert(key, cacheItem, null, dt, TimeSpan.Zero);
  
          return IsCached(key);
      }
  
      return true;
  }
  
  public static bool AddItemToCache&lt;T&gt;(string key, Dictionary&lt;T, T&gt; cacheItem, TimeSpan ts)
  {
      if (!IsCached(key))
      {
          System.Web.HttpRuntime.Cache.Insert(key, cacheItem, null, Cache.NoAbsoluteExpiration, ts);
  
          return IsCached(key);
      }
  
      return true;
  }
  </code></pre>
  
  <p>and this is the linq query that is failing to compile:</p>
  
  <pre><code>private Dictionary&lt;int, string&gt; GetCriteriaOptions()
  {
      Dictionary&lt;int, string&gt; criteria = new Dictionary&lt;int, string&gt;();
      string cacheItem = "NF_OutcomeCriteria";
  
      if (DataCaching.IsCached(cacheItem))
      {
          criteria = (Dictionary&lt;int, string&gt;)DataCaching.GetItemFromCache(cacheItem);
      }
      else
      {
          Common config = new Common();
          int cacheDays = int.Parse(config.GetItemFromConfig("CacheDays"));
  
          using (var db = new NemoForceEntities())
          {
              criteria = (from c in db.OutcomeCriterias
                          where c.Visible
                          orderby c.SortOrder ascending
                          select new
                          {
                              c.OutcomeCriteriaID,
                              c.OutcomeCriteriaName
                          }).ToDictionary(c =&gt; c.OutcomeCriteriaID, c =&gt; c.OutcomeCriteriaName);
  
              if ((criteria != null) &amp;&amp; (criteria.Any()))
              {
                  bool isCached = DataCaching.AddItemToCache(cacheItem, criteria, DateTime.Now.AddDays(cacheDays));
  
                  if (!isCached)
                  {
                      ApplicationErrorHandler.LogException(new ApplicationException("Unable to cache outcome criteria"), 
                          "GetCriteriaOptions()", null, ErrorLevel.NonCritical);
                  }
              }
          }
      }
  
      return criteria;
  }
  </code></pre>
  
  <p>It's the line isCached = DataCaching..... that I am getting the error.  I've tried casting it to a dictionary (<code>Dictionary&lt;int, string&gt;</code>), doing a <code>.ToDictionary()</code>, but nothing works.</p>
  
  <p>Anyone got any ideas?</p>