Q:

C# Linq DataContext Table: A polymorph cast

I am trying to write a method:
public Table<ParentType> GetTableFromContext()    {
   //return a table of type Table<ChildType> 
}

Yes, I could solve this using Generics:
public Table<T> GetTableFromContext<T>() where T : ParentType   {
   //return a table of type Table<T> 
}

But I'd prefer not to. (I'd have to use generics in all base classes then)
Is there a solution to refer to a table with a less specific type?

A:

You can solve this problem with the help of covariation, but at this case you should use interface ITable instead of class Table as return type of your method:
public interface ITable<out T>
{}

public class Table<T> : ITable<T>
{}    

public ITable<ParentType> GetTableFromContext() {
    return new Table<ChildType>();
}

