title: Generic Linq2SQL repository problem with inheritance
body: <p>I have a generic Repository implementation on top of Linq2SQL. Basically, it uses Table on data context to get the IQueryable and then run the queries over it:</p>
  
  <pre>
  <code>private readonly IQueryable _queryable;
  private readonly DataContext _context;
  
  public Repository(DataContext context)
  {
      _context = context;
      _queryable = context.GetTable().AsQueryable();
  }</code>
  </pre>
  
  <p>The problem is with inheritance. If I have two inherited tables, an exception is thrown:</p>
  
  <pre>
  <code>[InheritanceMapping(Code="1", Type=typeof(Staff))]
  [InheritanceMapping(Code="2", Type=typeof(Resident), IsDefault=true)]
  public class Person { }
  public class Resident : Person { }
  public class Staff : Person { }
  </code></pre>
  
  <p>now when creating Repository an exception is thrown:</p>
  
  <p>System.InvalidOperationException: Could not retrieve a Table for inheritance subtype 'Staff', try Table of Person instead.</p>
  
  <p>Now the story does not end here. I CAN switch to using Repository for querying, but when it comes down to saving objects, I need to use the derived type (i.e. Staff) or another exception will be thrown, so I end up having two different repository instances: one for save and update operations and the other for querying, while one should be enough.</p>
  
  <p>Any help is very much appreciated.</p>