我已閱讀了一些關於約束的信息,並試圖在我的存儲庫模式中實現它。存儲庫模式的通用接口繼承和類實現
我想下面的東西,但不能完全得到它編譯。
public interface IRepository<T>
{
void GetAllData<T>();
}
//This needs to inherit from IRepository
//T has to be a model class
//V has to be a class that implements IEmployeeRepo
public interface IEmployeeRepo<T, V> where V : EmployeeRepo where T : class : IRepository<T>
{
void DoSomethingEmployeeRelated();
}
//Dont think this inheritance is correct
public class EmployeeRepo<Employee, this> : IEmployeeRepo
{
}
//My example model class
public class Employee
{
public string Name {get;set;}
}
你的代碼中有太多的錯誤(我至少可以發現3個)來理解你想要的。 – leppie 2011-01-24 11:34:41
閱讀上面的註釋IEmployeeRepo,我也提到它不會編譯 – Jon 2011-01-24 11:35:52