我需要澄清一些事情.
有人积极,2个VOs(国家,州政府).
我想在我的表示层中加载所有国家/地区(我正在使用mvc)
Evan说你只使用存储库(IPersonRepository)来处理root实体(它应该总是只返回对Aggregate Root的引用)
public interface IPersonRepository()
{
void savePerson(Person p);
void removePerson(Person p);
Ilist<Person> getPerson();
}
Run Code Online (Sandbox Code Playgroud)
我通常做的是解决这个问题:
在IPersonRepository中添加此方法
IList<Country> LookupCountrysOfPerson();
Run Code Online (Sandbox Code Playgroud)
在Infra层实现Domain接口,如下所示:
public IList<Person> LookupCountrysOfPerson()
{
return Session.CreateQuery("from Countrys").List<Person>());
}
Run Code Online (Sandbox Code Playgroud)
我的伙伴说错了.
有时您必须牺牲您的域模型才能完成某项任务
做这个的最好方式是什么?
请带代码!:)