title: Nested Query on Entity Framework MVC3
body: <p>I have tried several things but it does not work. Basically, I want to add nested query on EF MVC3. </p>
  
  <p>SQL Query:</p>
  
  <blockquote>
    <p>select * from Book where Book_PK in ( select Book_Ref from Library
    where Library_Ref='18bd9526-f3e9-4d5b-86cd-ccfea64b6f7b' ) </p>
    
    <p>Book_PK is primary key of Book<br>
    Book_ref is foreign key to Book</p>
    
    <p>Library_Ref is just attribute to filter the Book_ref</p>
  </blockquote>
  
  <p>I have 2 tables: Book and Library which are connected through foreign key.</p>
  
  <p>I only have one input, which is id, but this is not the primary key of Library.
  I have tried:</p>
  
  <pre><code>`
  School.Models.Entities.SchoolAll db = new Models.Entities.SchoolAll(); // db consists whole database
  
  var temp = db.Books.Where(e =&gt; e.Book_PK.Contains(db.Libraries.Where(f =&gt; f.Library_Ref == id))).ToList();
  // where id is one of the field of Library`
  </code></pre>
  
  <p>each Library entity may have one or may Book entity. So, the result of the query is supposed to be as list. I need to save this list into one variable. Can anyone help me?</p>