Actually, this has been one of the difficulties I ran into when coming to grips with DDD.
Ideally your domain object should only contain domain logic. Your repositories should contain data logic, and if you have logic that needs to be performed across multiple repositories it should reside in a domain service which is also included in your domain assemblies.
In my experience it's best to keep any data related logic out of your domain model, so you shouldn't find methods like IsDuplicate (or similar) that are going to have to examine the contents of a repository to get their info. Instead move these out to your repository or a service.
Sometimes you find yourself with the same multi-repository action need when developing a the application that is going to use your domain - in this case you would generally use "application services" which reside in your application.
Of course, all of this is up for some debate - not everyone agrees on a) how you should do it and b) even if they agree on the approach not everyone agrees on the same descriptive terms.
There's actually a fair bit of info floating around on the web about this stuff, but I'm afraid I can't provide you with any urls as I've had to do a brain purge since I started gathering my info. If you google some of the terms I've provided above you'll find some stuff, no doubt. You could also try reading Domain Driven Design by Eric Evans - good book.
Cheers,
Symon.
|