title: LINQ to Entities does not recognize the method 'Int32 Parse(System.String)' method, and this method cannot be translated into a store expression
body: <p>I am using Entity Framework, and I have a line of code that is taking a var and translating it back to an iint for the database.</p>
  
  <pre><code>var record = context.enrollments.SingleOrDefault
    (row =&gt; row.userId == int.Parse(UserID) &amp;&amp; row.classId == int.Parse(ClassID));
  </code></pre>
  
  <p>Whenever I try to run it I receive rhis error. "LINQ to Entities does not recognize the method 'Int32 Parse(System.String)' method, and this method cannot be translated into a store expression."</p>
  
  <p>I have tried this as well</p>
  
  <pre><code> var record = context.enrollments.FirstOrDefault
    (row =&gt; row.userId == Convert.ToInt32(UserID) 
    &amp;&amp; row.classId == Convert.ToInt32(ClassID));
  </code></pre>
  
  <p>and all I receive is this error message, "LINQ to Entities does not recognize the method 'Int32 ToInt32(System.String)' method, and this method cannot be translated into a store expression</p>
  
  <p>and finally I have tried this as well, which I know is unusual, but it has worked in the past for similar situations.</p>
  
  <pre><code>var record = context.enrollments.SingleOrDefault
    (row =&gt; row.userId == CommonDLL.Sanitize&lt;int&gt;.ConvertType(UserID) 
    &amp;&amp; row.classId == CommonDLL.Sanitize&lt;int&gt;.ConvertType(ClassID));
  </code></pre>
  
  <p>In which I get this error. As you can see I have tried seveal different things and nothing is working, so any help would be great.</p>