我试图定义一个特定的接口为我所有的库实现,比仅仅是这样的:IRepository与IRepository <T>
public abstract class GeneralizedRepository
{
readonly IDataModel _Model;
public GeneralizedRepository(IDataModel Model) {
if (Model == null)
throw new NullReferenceException();
_Model = Model;
}
public IDataModel DataModel { get { return _Model; } }
public abstract IEnumerable<T> GetAll<T>();
public abstract T GetOne<T>(Func<T, bool> predicate);
public abstract bool Contains<T>(Func<T, bool> predicate);
public abstract void Add<T>(T entity);
public abstract void Update<T>(T entity);
public abstract bool Remove<T>(Func<T, bool> predicate);
}
这是一类,因为我得到的资料库有共同的实例的DataModel
现在我有具体的实现为:
public class DetailRep : GeneralizedRepository
{
public DetailRep(IDataModel Model) : base(Model) { }
public DetailRep(UnitOfWork Unit) : base(Unit.Model) { }
public override IEnumerable<T> GetAll<T>() {
throw new NotImplementedException();
}
public override T GetOne<T>(Func<T, bool> predicate) {
throw new NotImplementedException();
}
public override bool Contains<T>(Func<T, bool> predicate) {
throw new NotImplementedException();
}
public override void Add<T>(T entity) {
throw new NotImplementedException();
}
public override void Update<T>(T entity) {
throw new NotImplementedException();
}
public override bool Remove<T>(Func<T, bool> predicate) {
throw new NotImplementedException();
}
}
但它是一个详细库,我的意思是,我要全部更换牛逼的该类型详细
但错误是在编译时抛出:
类型参数声明必须是一个标识符不是一个类型
问题的标题中的类型没有出现在问题中!?你能再次检查你的问题吗?并提供有关错误的更多详细信息。例如,产生错误的行?对基地(...)的呼叫是错误的,但在解释之前,我首先需要了解你真正想要的。 – Achim 2011-04-21 19:33:27