title: How can I do an eager load when I don't know the name of the property I want to load?
body: <p>I have a generic repository and when I'm using a DoQuery method to select objects from the database, I need to load some of the related entities in order to not get nulls in the place of the fields that are foreign keys.</p>
  
  <p>The problem is that the repository is generic, so I do not know how many properties need loading or what their names are (unless there's some way of getting them) how can I make it so that all of the foreign keys have their entities loaded while still keeping this repository generic?</p>
  
  <p>Here's the DoQuery method:</p>
  
  <pre><code>    public ObjectQuery&lt;E&gt; DoQuery(ISpecification&lt;E&gt; where)
      {
          ObjectQuery&lt;E&gt; query = (ObjectQuery&lt;E&gt;)_ctx.CreateQuery&lt;E&gt;("[" + typeof(E).Name + "]").Where(where.EvalPredicate);
          return query;
      }
  </code></pre>
  
  <p>And a <a href="http://www.codeproject.com/KB/database/ImplRepositoryPatternEF.aspx" rel="nofollow noreferrer">link to the original code for the entire repository.</a></p>
  
  <p>I posted this once before and never got the answer to it but I figure this one is a little bit more relevant since before people were assuming I knew the property names and could do:</p>
  
  <p><code>.Include("PropertyNameIKnowNeedsToBeLoaded")</code> </p>
  
  <p>Here's the <a href="https://stackoverflow.com/questions/1655360/having-troubles-loading-related-entities-eager-load-with-objectcontext-createqu">question I posted before</a> hopefully that will provide a little information on where I'm at with this.</p>
  
  <p>Any help is appreciated.</p>
  
  <p>Thanks,<br/>
  Matt</p>