我已阅读了一些关于约束的信息,并试图在我的存储库模式中实现它。存储库模式的通用接口继承和类实现
我想下面的东西,但不能完全得到它编译。
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