请看这个简单的、虚构的例子:
UserRepository.GetAllUsers(); UserRepository.GetUserById();
不可避免地,我会有更复杂的“查询”,比如:
//returns users where active=true, deleted=false, and confirmed = true
GetActiveUsers();
我在确定存储库的责任范围时遇到了麻烦。GetActiveUsers()代表一个简单的“查询”。它应该属于存储库吗?
如果涉及一些逻辑,比如:
//activate the user, set the activationCode to "used", etc.
ActivateUser(string activationCode);