title: EF: One-to-many relationship - querying for a subset of the data
body: <p>I am trying to fetch a collection of entities from a one-to-many relationship as an IQueryable so I can filter the data down before fetching this from the database. </p>
  
  <p>To make it clear, consider the following example: </p>
  
  <p>I currently have an entity "User" which has a collection of Pictures: </p>
  
  <pre><code>public virtual ICollection&lt;Picture&gt; Pictures{ get; set; }
  </code></pre>
  
  <p>The Picture entity may or may not belong to a User, and hence, doesnt have the User property in its definition.</p>
  
  <p>A user may have thousands of pictures, but I would like to select the first 10 for example, ordered by Picture.Id. Is there a way to do this?</p>
  
  <p>Maybe something along the lines like: </p>
  
  <pre><code>IQueryable&lt;ICollection&lt;Picture&gt;&gt; pictures = context.Users.Where(u=&gt;u.UserId == userId).Select(c =&gt; c.Pictures) 
  </code></pre>
  
  <p>Thanks!</p>