title: ASP.NET MVC C# Select and Where Statements
body: <p>I'm having trouble understanding .Select and .Where statements. What I want to do is select a specific column with "where" criteria based on another column.</p>
  
  <p>For example, what I have is this:</p>
  
  <pre><code>var engineers = db.engineers;
  var managers = db.ManagersToEngineers;
  List&lt;ManagerToEngineer&gt; matchedManager = null;
  Engineer matchedEngineer = null;
  
  if (this.User.Identity.IsAuthenticated)
  {
      var userEmail = this.User.Identity.Name;
      matchedEngineer = engineers.Where(x =&gt; x.email == userEmail).FirstOrDefault();
      matchedManager = managers.Select(x =&gt; x.ManagerId).Where(x =&gt; x.EngineerId == matchedEngineer.PersonId).ToList();
  }
  if (matchedEngineer != null)
  {
      ViewBag.EngineerId = new SelectList(new List&lt;Engineer&gt; { matchedEngineer }, "PersonId", "FullName");
      ViewBag.ManagerId = new SelectList(matchedManager, "PersonId", "FullName");
  }
  </code></pre>
  
  <p>What I'm trying to do above is select from a table that matches Managers to Engineers and select a list of managers based on the engineer's id. This isn't working and when I go like:</p>
  
  <pre><code>matchedManager = managers.Where(x =&gt; x.EngineerId == matchedEngineer.PersonId).ToList();
  </code></pre>
  
  <p>I don't get any errors but I'm not selecting the right column. In fact the moment I'm not sure what I'm selecting. Plus I get the error:</p>
  
  <blockquote>
    <p>Non-static method requires a target.</p>
  </blockquote>