title: Linq filter model by another Table
body: <p>I have two separate tables in my solution: Tickets and UsersInRoles.  Each Ticket has a Technician attached to it that looks at a third table: Users.  However, A users role is not saved in the Users Table; it is saved in the UsersInRoles table. Now I need to filter all tickets by technicians that have a role of New Media. I have searched and this are two different approaches that I have and neither is working.</p>
  
  <p>First Approach:</p>
  
  <pre><code>var NewMediaIds = db.usersInRoles.Select(nm =&gt; nm.RoleId == new Guid(Properties.Settings.Default.NewMediaID)).ToList();
  model = model.Where(t =&gt; NewMediaIds.Contains(t.TechnicianId));
  </code></pre>
  
  <p>and I get this error:</p>
  
  <blockquote>
    <p>Error 2   Argument 1: cannot convert from 'System.Guid' to
    'bool'    C:\Dev\HelpDesk\HelpDesk.WebUI\Controllers\TicketController.cs  561 67  HelpDesk.WebUI</p>
    
    <p>Error 1   The best overloaded method match for
    'System.Collections.Generic.List.Contains(bool)' has some
    invalid
    arguments C:\Dev\HelpDesk\HelpDesk.WebUI\Controllers\TicketController.cs  561 46  HelpDesk.WebUI</p>
  </blockquote>
  
  <p>Second Approach:</p>
  
  <pre><code>model = model.Where(t =&gt; t.TechnicianId == db.usersInRoles.Where(u =&gt; u.RoleId == new Guid(Properties.Settings.Default.NewMediaID)).UserId);
  </code></pre>
  
  <p>and I get this error:</p>
  
  <blockquote>
    <p>Error 3   'System.Linq.IQueryable' does not
    contain a definition for 'UserId' and no extension method 'UserId'
    accepting a first argument of type
    'System.Linq.IQueryable' could be found
    (are you missing a using directive or an assembly
    reference?)   C:\Dev\HelpDesk\HelpDesk.WebUI\Controllers\TicketController.cs  563 153 HelpDesk.WebUI</p>
  </blockquote>