Is this a good or bad idea?
public interface IRepository<T>
{
...
IList<T> Get(Func<T, bool> predicate)
...
}
I mean – it seems really powerful addition and i could implement it too (at least – to some level) but my guts tells me it’s kind a wrong. Could anyone enlighten me?
Well, it certainly is a powerful feature. The problem is: introducing it in the interface will force all implementations of
IRepositoryto provide a suitable definition — which might not be possible (or at least really hard) depending on the implementation (say, an implementation backed by a database connection or something).Maybe, you should instead do
and provide
Getonly, if the implementation can do it efficiently.