Over the past few months, we've been implementing an application using DDD & CQRS. One thing that I still struggle with is the best way to persist data, especially to multiple datasources of different types.
Up to this point, we've used a DAL interface layer, with multiple partial implementations of that DAL. Then in our Domain layer, we use repositories to construct/save our domain objects to n number of DALs. This works fine, until we get to some more advanced operations like pagination and searching. This has required us to not only map our data, but map our ordering/searching/pagination criteria.
I've read opinions that we should just be exposing whatever the persistence layer is (IE Entity Framework, Filesystem, web services) to the DDD layer and have the repositories access those directly, so they can take advantage of the features built into things like ORMs. This feels like a leaky abstraction to me.
Is there a pattern I'm overlooking that will help us solve these issues?