2 ms·
There is no need for tight coupling or to expose an Iqueryable. You can write your repository with a method signature like this.... Find(<Expression<Func<Empl
by scarface74 9y ago
There is no need for tight coupling or to expose an Iqueryable.
You can write your repository with a method signature like this....
Find(<Expression<Func<Employee,bool>> query)
{....}
With Employee being a regular old undecorated POCO.
Then if you call it:
Find(e => e.id == 5)
The repository can be searching for data in a SQL Server database using Entity Framework or a Mongo database using the Mongo driver or even an in memory list for unit testing and the calling code doesn't care.
Yes the expression will be translated to the appropriate query (MongoQuery or SQL) without any coupling.
You return a List<Employee> not an IQueryable.