title: Simple Example Subquery Linq
body: <p>T-SQL Query</p>
  
  <pre><code>Select * from dbo.User_Users
  Where UserID IN (Select UserID from Course_Enrollments)
  </code></pre>
  
  <p>LINQ to Entities alternative of Above Query</p>
  
  <pre><code>var innerquery = from en in Course_Enrollments
  select en.UserID;
  
  var query = from u in User_Users
  where innerquery.Contains(u.UserID)
  select u;
  </code></pre>
  
  <p>There are alot of complex subqueries on stackoverflow, i just want to see a simple example of how a simple subquery is done via linq.This is how i done it, however its not good because it sends 2 queries to the database.</p>