开发者

DDD Business Model to Relational Model mapping

I'm trying to figure out where (in the various layers) the business entities should start and the object to table mapping end. Should business entities surface out of the repository layer or out of the service layer?

I'm wondering cause initially i thought it should surface from repository layer, but let's see my concerns in this case. A member's repository shuold return business model Member entity which have, as a pr开发者_运维问答operty, the member's country. Member's country would be a string (Germany, USA, ..) and this would mean that the member's repository would benefit from using a country repository. Is this right or repositories should work separate. Or should the service layer builds and return the business model Member entity using the various repositories? If my assumption that Business Entities should surface from repository layer, should the caching also happen at repository level? I mean, mapping back and forth from Countries or to a more complex relation should benefit from caching at repository level?

Thanks


When you have objects which contains only code and label, which are often called "reference values" or "nomenclature", they should be treated differently from other objects. This may not be adressed by domain-driven design.

My advice : only the code (the foreign key) is generally useful in the business layer, so never load a reference value in the business tier, put them all at startup time in an updatable cache accessible from the presentation layer.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜