title: How to partition a query and load only a few properties with Linq to Entities?
body: <p>I have the following POCOs:</p>
  
  <pre><code>public Ticket
  {
      public int Id { get; set; }
      public int IdOwner { get; set; }
      public int IdDependency { get; set; }
      public string SerialNumber { get; set; }
  
      public Owner Owner { get; set; } 
      public Dependency Dependency { get; set; }
  }
  
  public Owner 
  {
      public int Id { get; set; }
      public string Name { get; set; }
      // Other attributes
  }
  
  public Dependency 
  {
      public int Id { get; set; }
      public string Name { get; set; }
      // Other attributes
  }
  </code></pre>
  
  <p>I want to return a <code>List</code> of Tickets that has only <code>Owner Name</code> and <code>Dependency Name</code>. The problem is, i will write a <code>where</code> with <code>Owner</code> if in my filter i pass the <code>OwnerId</code>, and the same to <code>Dependency</code>. Look to my filter:</p>
  
  <pre><code>public List&lt;Ticket&gt; SelectTickets(string SerialNumber, int IdOwner, int IdDependency)
  {
      IQueryble&lt;Ticket&gt; query = context.Tickets.Where(t =&gt; t.SerialNumber == SerialNumber);
  
      if (IdOwner != 0)
      {
          query = query.Where( ?? );
      }
  
      if (IdDependency!= 0)
      {
          query = query.Where( ?? );
      }
  
      return query.ToList();
  }
  </code></pre>