title: How to query related entities (1:N relation) in entity framework
body: <p>What is a better way to get related entities in scenarios <a href="http://postimage.org/image/2x3bfw61w/" rel="nofollow">like this: {class diagram here}</a>?<br>
  I wrote two ways (please also note the difference in class diagram)... Project has property with ICollection of Tasks, but Member doesn't. Both ways are working and I would like to know, which one is correct (better/faster). Or if none is good, then what is a correct way in these simple scenarios?<br>
  Code:  </p>
  
  <pre><code>    using (var db = new EntitiesContext())
          {
              // way A
              Project project = db.Projects.Include("Tasks").First();
              List&lt;Task&gt; projectTasks = project.Tasks.ToList();
              count = projectTasks.Count;
  
              // way B
              Member member = db.Members.First();
              IQueryable&lt;Task&gt; memberTasks = from t in db.Tasks
                                             where t.AssignedTo.Id == member.Id
                                             select t;
              count = memberTasks.Count();
          }
  </code></pre>
  
  <p>I am using EF 4.1 Code First.<br>
  Btw: Don't worry about the result (getting count) too much. This is just a piece of test code, I would of course like to query more useful informations in future.</p>