0
public interface IMasterService<out T> : IDisposable
{
        T GetByID(int id);
        IEnumerable<T> GetAll();
        IEnumerable<T> Where(Expression<Func<T, bool>> func);
        int AddNew(T newEntity);
}

无效方差:类型参数“T”必须在“IMasterService.Where(System.Linq.Expressions.Expression>)”上逆变有效。“T”是协变的。

4

1 回答 1

0

简而言之:如果你想使用<out T>那么你应该返回T,如果你想使用<in T>你需要T作为参数传递。不可能在一个界面上out同时使用。in现在我不能说为什么你不能使用Expression<Func<T, bool>>,但我会试着找出一些关于它的东西。

于 2012-07-27T11:55:47.083 回答