I need an advice on DDD (Domain Driven Design) and implementation of Repository pattern and encapsulation. To my understanding is that Repository pattern enables me to put all the database access logic in one place and abstract that logic from other parts of application. On the other side there is orm (Nhibernate, EntityFramework...) with its support for Linq and IQueryable. My toughts are: 1. If I am using repository then I should not use IQueryable as my return type bust instead use IEnumerable. Because if I use IQueryable then this would allow leaking database code to other application layers (IE would allow other devs to do queries in mvc controller where they don't belong). But every controls use IQueryable to access data and does this because is easier. If I use IQueryable as return type of my repository methods then: - I allow other developers to do database querying in other layers of application (and I think this should not be possible) - It will leak my domain entities (domain model) to other layers of applications (ie. User interface) but should not, instead DTO should be used.
My question is is IQueryable a good practice in DDD?