Loading a Value object in List or DropdownList, DDD

前端 未结 4 771
春和景丽
春和景丽 2020-12-05 08:55

I need to clarify something.

Have Person Aggreagate , 2 VOs (Country, StateProvince).

I want to load all country in my presentation layer (i am using mvc)

4条回答
  •  借酒劲吻你
    2020-12-05 09:27

    I would say it's unlikely that you need country to be an entity. I suspect that country is nothing more than reference data, much like a person's title would be. Is there any behavior associated to country in your domain? I suspect it's just what's printed onto letters/envelops.

    This question is somewhat similar to this one which I answered a while back:

    Simple aggregate root and repository question

    My suggestion is that you implement a Lookup service that your client can make use of and which is cached. Ignore the rules of DDD and anything to do with aggregates or repositories for this. As someone else has mentioned, this is where CQRS's ideology comes into play; the client shouldn't have to go through the domain in order to get data. The domain is purely transactional, not designed for queries.

    This article explains how to build a generic lookup service for reference data for things that typically fill dropdowns in the UI (i.e. Title, Country etc)

    http://wtfperminute.blogspot.com/2011/02/working-with-reference-data-lookups.html

提交回复
热议问题