Hi all, Repository[^] pattern with Unit of Work[^] and Dependency Injection, seem to be a universaly accepted solution for ASP.NET + EF applications. There are still some minor questions that I would like to ask here. Consider the following method from a generic IRepository
interface:
public IQueryable Get() where T : class
{
return Set();
}
I wonder, is it a good practice in reveling IQueryable
interface to the callers. This means that the calling method can add filters/paggin/sorting, but at the same time the repository itself becomes not unit testable (you cant rely anymore on what the repository will actually return). The caller can even add a non-translatable predicate that will break at runtime. So, is it a good practice in hiding IQueryable
interface from the caller, and defining IEnumerable
interface instead? Also, I wonder how do you perform integration tests on repositories? Do you use SQL CE4
, full SQL Server
, or just Fake objects on DbContext
? Appreciate your response, With regards