'Interface<out T> with method returning Task<T> error

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.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source