title: LINQ to Entities does not recognize the method System.ObjectCompareObjectEqual
body: <p>I had a code segment on an asp.net page in the code-behind file. I decided to move it into a public subroutine in a module (general_functions.vb). Once I did this, however, the code no longer works - it throws an error.</p>
  
  <p>On the original code-behind I replaced the original code with a call like so:</p>
  
  <pre><code>DeleteResidency(people_id, semester, year)
  </code></pre>
  
  <p>Now in my general_functions.vb I created a public subroutine like follows:</p>
  
  <pre><code>Public Sub DeleteResidency(delpeople_id, delsemester, delyear)
      Using dbContext as pbu_housingEntities = New pbu_housingEntities
          Dim remove_selection = (From p in dbContext.Residents _
                                 Where p.people_code_id = delpeople_id _
                                 Where p.year = delyear _
                                 Where p.semester = delsemester _
                                 Order By p.id Descending _
                                 Select p).FirstOrDefault
      End Using
  End Sub
  </code></pre>
  
  <p>There is more code to it than that, but the code above is what throws the error. The error I get is:</p>
  
  <blockquote>
    <p>LINQ to Entities does not recognize the method 'System.Object
    CompareObjectEqual(System.Object, System.Object, Boolean)' method, and
    this method cannot be translated into a store expression.</p>
  </blockquote>
  
  <p>Can anyone help me understand why this is occurring?</p>