title: Linq Extension method for Join
body: <p>I am in the process of learning LINQ, ASP.NET, EF, and MVC via online video tutorials. I would love some help understanding Joins in LINQ extension method syntax.</p>
  
  <p>For simplification, I have two tables (these map to a SQL DB):</p>
  
  <pre><code>User Table:
      public int userID{get;set;}
      public string firstName{get;set;}
      ...
  
  Address
      public int ownerID{get;set;}
      public int value{get;set;}
      public string Nickname{get;set;}
      public string street{get;set;}
      public string zip{get;set;}
      ...
  </code></pre>
  
  <p>Let's say I want to find all the property that a particular user owns. I believe I can do something like this:</p>
  
  <pre><code>var test = db.User
      .Join(db.Address, user =&gt; user.userID, add =&gt; add.ownerID, (user, add) =&gt; new { user, add });
  Source: http://byatool.com/c/linq-join-method-and-how-to-use-it/
  </code></pre>
  
  <p>This should be equivalent to </p>
  
  <pre><code>SELECT * FROM User a JOIN Address b on a.userID = b.ownerID 
  </code></pre>
  
  <p>Please confirm that this is correct.</p>
  
  <p>Now, what if I wanted to find all property that a particular user owns that has a <code>value greater than x</code>. Let's take it a step further and say x is a result from another LINQ query. How do I force execution of <code>x</code> inside of a second query? Do I even have to consider this, or will LINQ know what to do in this case?</p>
  
  <p>Thanks</p>
  
  <p>EDIT:
  When I try to use the result of a query as a parameter in another, I am required to use a greedy operator to force execution. Many people like to use <code>.Count()</code> or <code>.ToList()</code>. I only expect <code>x</code> (from example above) to return 1 string by using <code>.Take(1)</code>. If I append <code>ToList()</code> to the end of my first query, I am required to use x[0] in my second query. This seems like a messy way to do things. Is there a better way to force execution of a query when you know you will only have 1 result?</p>