title: Entity Framework : get all entities with specific type
body: <p>I am using Entity Framework to read/write data to the DB and wondering if there is a way to get the entities by type. For example: I have <code>Student</code> table and <code>Classroom</code> table (in reality, I have bunch of tables). I would like to get all the students by using the type or entity name. Basically I need something generic to read the data from the DB. </p>
  
  <p>The solution I have is to use reflection to read the <code>DbContext</code> properties that returns <code>IQueryable</code>, but it seems there should be another way of doing it. If so, can someone tell me how to do it? </p>
  
  <p>I need something like this: </p>
  
  <p><code>dbContext.GetEntities&lt;T&gt;()</code> </p>
  
  <p>or </p>
  
  <pre><code>dbContext.GetEntities(Type entityType)
  </code></pre>