i think this is the first time i’ve not been able to find the answer to my question just by searching.
I’m doing some prototypes for a remake of our company system and i hit upon a problem i can’t seem to get my head around.
I’m trying to utilise a reasonably generic DAO coupled dependency injection.
The problem i’m having is that i’d like to use a third party library for query definition within the method of the interface.
An example
public interface TestDAO<TEntity>
{
/// <summary>
/// get ALL the things
/// </summary>
/// <returns></returns>
IEnumerable<TEntity> GetAll();
/// <summary>
/// Runs a supplied "where" clause and returns ALL the matched results
/// </summary>
IEnumerable<TEntity> FindAll(Specification<TEntity> specification);
}
Specification in this case is an object from a third party library called LinqSpecs.
It is my understanding that by doing this i’m essentially forcing a dependency on the third-party library on any implementation of the interface.
I understand that I can just forego using the library but if possible i’d like to keep it, at least until we’ve assessed its usefulness.
My question is, is there a way of doing this(or something similar) without dragging the third party dependency with it.
Thanks in advance.
You actitually want to give your interface TestDAO a searchfilter that can be hidden behind your own interface
The searchfilter implementation contains the actual data
The downside of this aproach is that
your TestDAO implementation must do some ugly casting to get the LinqSpecs.Specification