【发布时间】:2016-06-28 22:45:20
【问题描述】:
DDD 存储库是否应该始终返回聚合及其所有值对象和实体?
例如,我有 Invoice 对象,其中包含它的类型和项目。
Invoice
--Id
--Issuer
--InvoiceType
--Items
数据保存在 4 个 SQL 表中。
Invoices (FK to invoice type, FK to issuers),
InvoiceTypes
Items(fk to Invoice)
Issuers
如果存储库应始终返回完整状态的聚合,如果我需要获取 50 张发票并仅显示 ID 和 IssuerName,那么包含 InvoiceType 和 Items 是否有点矫枉过正。
示例
InvoiceRepository
{
//should this also fetch InvoiceTypes and items from SQL, or i need separate invoice model for this
public List<Invoice> FetchForListing(int page, int take);
}
【问题讨论】:
标签: domain-driven-design ddd-repositories