title: Entity Framework - Reflection
body: <p>I need to select Entity Objects based on the name of page controls.</p>
  
  <p>There are two scenarios where I need to access Entities based on a string (I am dynamically selecting these based on the names of user controls placed on a page:</p>
  
  <p>Example 1) - 
  Here I would like to somehow change db.PersonalDetails to a string substitution where the db.PersonalDetails is a variable.</p>
  
  <pre><code>EntityObject obj = null;
  obj = (from q in db.PersonalDetails where q.AppFormId==FormApplicationId select q).SingleOrDefault();
  </code></pre>
  
  <p>Example 2)
  Here I would like to dynamically set the return type, in this case it is PersonalDetail but I would like to be able to set this dynamically. I can use reflection to get the type but I am unable to then say " as obj.GetType() " as it errors.</p>
  
  <pre><code>EntityObject obj = null;
  obj = returnUpdatedObj(obj) as PersonalDetail;
  </code></pre>
  
  <p>Any help would be much appreciated. I am desperate to find a solution to this so if any more information is required to explain the issue please let me know.</p>