开发者

Populate VO in drop down list in UI

I have Person class which is root of its aggregate, this aggregate also contains country and state province as vo.

{Person, Country, StateProvince} - > Person is root aggregate.

// Public Person(string name, string country, state province,{other params}){}

// But now i am facing problem in UI, how will i populate Dropdown for Country and Stateprovince, through person because it is root aggregate, but i don't want any person's assigned Country or Stateprovince but i want list of all countries and their Stateprovince, so that user choose one from them

Do i manually create table for country and stateprovince and fill them with all values manually.If 开发者_如何学Goyes, then how will i get values from those tables in ddd .


Your model is trying to tell you something.

Country and StateProvince are probably not part of the Person Aggregate.

Remember the very handy "delete test" for an aggregate, ask if I delete this person do I also delete their country and StateProvince? I live in Canada, and you remove me from your system are you also going to delete the country Canada from your system as well?

No, you would not. You have two separate aggregates here Person and Location which would contain the Aggregate of {Country, StateProvince} If you delete a country you would very likely also delete all the states or provinces contained within it as well.

Just because Person references a class or has-a class doesn't make all the references part of that aggregate. Location is very common aggregate in many systems and regularly stands on it's own.

You should have a Person Repository that utilizes a LocationRepository and have the UI directly call the LocationRepository to obtain Location Aggregates.


You would populate your country and state province from different tables. You would then fill the drop downs from these tables. When working with a specific Person entity which has already got Country and StateProvince assigned you would bind them with master tables through id.

Hope that helps.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜