In this post I talked about using a generic base class to enable me to create repository classes without duplicating loads of basic plumbing code.
Each Repository is accessed through an interface. In the code below, I will only show one of the methods for the sake of brevity:
Interface:
IQueryable<Suggestion> All { get; }
Generic base class
public IQueryable<T> All
{
get { return _unitOfWork.GetList<T>(); }
}
Concrete class (implements the interface and extends the generic base class)
public IQueryable<Suggestion> All
{
get { return _unitOfWork.GetList<Suggestion>(); }
}
I anticipated that I would be able to simply strip the method out of the concrete class, and the compiler would use the generic base class implementation instead and work out that was intended to satisfy the interface. But no!
When I strip the method out I get the old 'does not implement interface member' error.
If I can't do this, have my efforts to use a generic base class not been pointless? Or is there a way around this?