C# 在实体之间建立适当的关系
用户配置文件在系统上具有配置文件属性。 属性可以是不同的类型(关于你、职业、任何事情) 现在我想在以下两者之间建立适当的关系:C# 在实体之间建立适当的关系,c#,nhibernate,domain-driven-design,C#,Nhibernate,Domain Driven Design,用户配置文件在系统上具有配置文件属性。 属性可以是不同的类型(关于你、职业、任何事情) 现在我想在以下两者之间建立适当的关系: 配置文件和配置文件属性 配置文件属性和配置文件属性类型(我不想将枚举用作数据类型) Profile.cs public List<ProfileAttribute> Attributes {get; set;} ProfileAttributeType.cs public List<ProfileAttribute> Attributes {g
public List<ProfileAttribute> Attributes {get; set;}
ProfileAttributeType.cs
public List<ProfileAttribute> Attributes {get; set;}
public string AttributeType {get; set;}
公共列表属性{get;set;}
公共字符串AttributeType{get;set;}
这是遗留代码和数据库,我正在尝试使用ddd方法构建应用程序并生成数据库表,所以我坚持以下几点
一个配置文件
具有多个配置文件属性
。因此,我有one-to-many
通过profile-side
我无法通过ProfileAttribute
侧来计算关系。所有ProfileAttribute都属于一个配置文件还是属于多对多的配置文件?这个响应属性让我感到困惑。你会怎么做
另外,对于ProfileAttribute和ProfileAttributeType,我有以下内容
一个
ProfileAttribute
通过ProfileAttribute
侧有许多AttributeType
,通过ProfileAttribute
侧我有多对一
(许多类型可以属于多个ProfileAttributes)首先,似乎奇怪的是,ProfileAttributeType
本身包含一个ProfileAttribute
的集合。也许它会有一个专用类型的属性集合
就
Profile
和ProfileAttribute
之间的关系而言,属性应该是与Profile聚合相关联的值对象。这意味着这种关系是一对多的。换句话说,一个概要文件可以包含多个属性,但是一个属性属于一个概要文件。属性本身可以按属性类型分组。属性类型本身可以是一个实体或聚合,如果存在与属性类型相关联的行为。首先,ProfileAttributeType
本身包含一个ProfileAttribute
的集合似乎很奇怪。也许它会有一个专用类型的属性集合
就Profile
和ProfileAttribute
之间的关系而言,属性应该是与Profile聚合相关联的值对象。这意味着这种关系是一对多的。换句话说,一个概要文件可以包含多个属性,但是一个属性属于一个概要文件。属性本身可以按属性类型分组。如果存在与属性类型关联的行为,则属性类型本身可以是实体或聚合
public List<ProfileAttribute> Attributes {get; set;}
public string AttributeType {get; set;}