我正在阅读 subsonic 3 的源代码。在文件 IRepository.cs 中我发现以下内容:
public interface IRepository<T>
{
IQueryable<T> GetAll();
PagedList<T> GetPaged<TKey>(Func<T, TKey> orderBy, int pageIndex, int pageSize);
...many other lines
bool Load<T>(T item, Expression<Func<T, bool>> expression) where T : class, new();
bool Load<T>(T item, string column, object value) where T : class, new();
}
请注意,Load 方法被定义为泛型,并且它们的泛型类型名称与接口的泛型类型相同,这会导致编译器警告。
我的问题是: Load 方法真的是通用的还是错误的?如果这些方法是通用的,我们是否应该将类型名称从“T”更改为“E”之类的不同名称以使编译器满意?