2015-05-11 22 views
1

我有一個接口,我想使用泛型創建一個存儲庫列表。然而,IRepository旁邊的TThe type or namespace T could not be found。我如何創建一個屬於通用存儲庫列表的屬性?在接口中創建IRepository <T>的列表

public interface IDataAccess 
{ 
    IUnitOfWork UnitOfWork { get; set; } 
    IEnumerable<IRepository<T>> Repositories { get; set; } 

回答

5

您將需要以指定IDataAccess<T>對於要向下傳播的T類信息的Repositories財產。否則,編譯器無法確定類型是什麼。

+1

我做了'IDataAccess 其中T:class',編譯器不再拋出錯誤。謝謝。 –