title: LINQ DB List Contains Object
body: <p>I am trying to write a linq query, but it doesn't work. My DB consists of a EventDetails Table from where I get the Student, then I want to get foreach Student the Class (n:1). So I iterate the Class Table and check if the List of Students contains the Student. What am I doing wrong?</p>
  
  <p>The Code:</p>
  
  <pre><code>var students = db.EventDetails
      .Include("Room")
      .Include("Task")
      .Include("Student")
      .Where(x =&gt; x.Student != null)
      .Select(x =&gt; x);
  
  foreach (var s in students)
  {
      string studentClass = db.Class
      .Include("Students")
      .ToList()
      .Where(x =&gt; x.Students.Contains(s.Student))
      .Select(x =&gt; x.Name).ToString();
  }
  </code></pre>