如何在域驱动设计中建模一对多关系

时间:2016-08-08 10:50:59

标签: nhibernate domain-driven-design one-to-many

我使用域驱动设计并使用nhibernate作为ORM

我有一个名为Certificate的实体和一个名为Condition的实体,以及一个用于保存这两个实体之间一对多关系的中间表。

条件可以有多个证书

由于条件和证书是单独的agreagate根,并且基于域驱动的规则,我不能在另一个中持有agregate,只有agregateId可以放在其中。因此,在条件agregate下面放置代码不可能是真的

 private List<CertificateId> _certificateIdList; 
.
.
.
 public IReadOnlyCollection<CertificateId> CertificateIdList { get { return _certificateIdList.AsReadOnly(); } }

以下代码似乎也不正确

  'target_defaults': {
    'configurations': {
      'ChirpDebug' : {
        'inherit_from': ['Debug'],
        'msvs_settings': {
          'VCCLCompilerTool': {
            'RuntimeLibrary': '3'
          },
        },
      },
      'ChirpRelease' : {
        'inherit_from': ['Release'],
        'msvs_settings': {
          'VCCLCompilerTool': {
            'RuntimeLibrary': '2'
          },
        },
      },
    },
你能帮我模一下这段关系吗?

谢谢

1 个答案:

答案 0 :(得分:1)

这取决于您的业务规则,但如果没有规则涵盖相同条件的所有证书,那么您可以在conditionId中引用Certificate并依赖数据库查询来获取关联。 / p>

相关问题