A repository mimics an in-memory collection. What I have used before is a Contains
method as opposed to a Find
method, I guess you could have either. A query layer could also be used for this. Just as you have a CarRepository
you could have a CarQuery
. Trying to check for uniqueness in the domain is somewhat pesky. I would do a check for the sake of convenience but still rely on the DB to raise the exception since you should also handle that case. Using the specification pattern for this may be more effort than it is worth.
Since repository is a 'collection' I wouldn't have Commit
and Rollback
on there.