0
public interface IRepo<out T>
{
    Task<IEnumerable<T>> DbFetch();
}

I want the method to be a task because DbFetch() will be slow.

error: Invalid variance: the type parameter 'T' must be invariantly valid on 'IRepo.DbFetch()'. 'T' is covariant.

I understand the reasoning for the error but how to get around it so I could await on that method. Note: cannot remove out T because of design requirement elsewhere.

Camilo Terevinto
  • 31,141
  • 6
  • 88
  • 120
Tiju John
  • 933
  • 11
  • 28

0 Answers0