title: Convert string to int in LINQ to Entities?
body: <p>I have to convert a <code>string</code> value to <code>int</code>, but it seems LINQ to Entities does not support this.</p>
  
  <p>For the following code, I am getting an error.</p>
  
  <pre><code>var query = (from p in dc.CustomerBranch
               where p.ID == Convert.ToInt32(id) // here is the error.
               select new Location()
               {
                   Name      = p.BranchName,
                   Address   = p.Address,
                   Postcode  = p.Postcode,
                   City      = p.City,
                   Telephone = p.Telephone
               }).First();
  return query;
  </code></pre>
  
  <blockquote>
    <p>LINQ to Entities does not recognize the method '<code>Int32 ToInt32 (System.String)</code>', and this method can not be translated into a store expression.</p>
  </blockquote>