In the following code compilation error occurs but I can’t understand why.
class RealMock<TEntity> : DataContext
{
public RealMock():base("")
{
}
public List<TEntity> inMemoryDataStore = new List<TEntity>();
public List<TEntity> GetTable<TEntity>() where TEntity : class
{
return inMemoryDataStore; //Compilation error
}
}
Cannot implicitly convert type ‘System.Collections.Generic.List [c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\mscorlib.dll]’ to ‘System.Collections.Generic.List [c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\mscorlib.dll]’
I believe this is because your GetTable method in parametrized, try defining it as