title: Entity Framework 4 - Generic method for retrieving entity by ID
body: <p>I am writing method for fetching single entities by their ID :</p>
  
  <pre><code>public Customer GetCustomer(int i_CustomerID)
  {
    return (from c in context.CustomerSet 
           where c.Id == i_CustomerID 
          select c).SingleOrDefault();            
  }
  
  public Movie GetMovie(int i_MovieID)
  {
    return (from m in context.MovieSet 
           where m.Id == i_MovieID 
          select m).SingleOrDefault();
  }
  </code></pre>
  
  <p>But I have many entities and this code repeats itself. I want to write a method like this:</p>
  
  <pre><code>public T GetEntityByID&lt;T&gt;(int i_EntityID)
  {
    return (from e in context.T_Set 
           where e.Id == i_EntityID 
          select e).SingleOrDefault();
  }
  </code></pre>
  
  <p>Is there a way to achieve that ?</p>