title: LINQ converting string to int
body: <p>I have this linq query which is making a selection and then trying to sum the totals so under each group key there is a sum total. The value is a string and I cannot sum a string. however when i try to convert to int I get an error:</p>
  
  <p>LINQ to Entities does not recognize the method 'Int32 ToInt32(System.String)' method, and this method cannot be translated into a store expression.</p>
  
  <pre><code> var dataSet = entities.BL_MT_CATEGORY
              .Distinct()
              .Where(d =&gt; (iGeography.FirstOrDefault() == "" || iGeography.Contains(d.Geography))
              &amp;&amp; (iRetailer.FirstOrDefault() == "" || iRetailer.Contains(d.Retailer))
              &amp;&amp; (iCountry.FirstOrDefault() == "" || iCountry.Contains(d.Country))
              &amp;&amp; (iAirport.FirstOrDefault() == "" || iAirport.Contains(d.Airport))
              &amp;&amp; (iShop.FirstOrDefault() == "" || iShop.Contains(d.StoreName))
              &amp;&amp; (iCategory.Contains(d.Category))
              &amp;&amp; (d.Values == "Sum of EuroValue"))
              .GroupBy(x =&gt; x.Category)
              .Select(g =&gt; new {
                  C201408 = g.Sum(x =&gt; Convert.ToInt32(x.C201408))
              })
              .ToList();
  </code></pre>