As you found out, this is a pretty bad idea. See here for more details: http://www.wekeroad.com/2014/03/04/repositories-and-unitofwork-are-not-a-good-idea/
But, in general, don't use repositories with RavenDB.
Question
Assume this setup:
interface IRepo
{
IEnumerable<Project> GetAllProjects();
}
class RavenRepo : IRepo
{
IEnumerable<Project> GetAllProjects()
{
return session.query<Project>();
}
}
class ApplicationService
{
IRepo repo;
public IEnumerable<Project> GetProjectsOrderedBySomething()
{
return repo.GetAllProjects().OrderBy(...);
}
}
This works fine, but I would like to add paging, all the way back to the Repo. If I just add it to GetAllProjects, the OrderBy wont work. I see three options:
I don't like the idea of deferring execution from outside the repository, but I guess option 2 is the most useful apart from that? Also, this puts the burden (and responsibility) of paging on the service, meaning that someone might miss the requirement to use paging.
Solution
As you found out, this is a pretty bad idea. See here for more details: http://www.wekeroad.com/2014/03/04/repositories-and-unitofwork-are-not-a-good-idea/
But, in general, don't use repositories with RavenDB.