2013-02-25 57 views
1

用户配置文件具有系统上的配置文件属性。 属性可以是不同的类型(AboutYou,Occupation,AnyhingElse)。在实体之间建立适当的关系

现在我想建立适当的关系之间:

  1. 个人资料和相关属性
  2. 轮廓属性和配置文件属性类型(我不想使用枚举作为数据类型)

档案。 cs

public List<ProfileAttribute> Attributes {get; set;} 

ProfileAttribute.cs

// holds user entered response on particular subject 
// describe yourself (if aboutYou type is selected) 
public string Response {get; set;} 
public ProfileAttributeType {get; set;} 

ProfileAttributeType.cs

public List<ProfileAttribute> Attributes {get; set;} 
public string AttributeType {get; set;} 

这是遗留代码和数据库,而我试图建立使用DDD方法和产生的数据库表的应用程序,所以我卡在下面。

其中一个Profile有很多ProfileAttribute。所以我通过配置文件侧面有one to many

我不能通过ProfileAttribute一边数字关系。是否所有个人档案属于一个档案或是否为many to many?此响应属性使我困惑。你会怎么做?

而且,ProfileAttribute和ProfileAttributeType我有以下

一个ProfileAttribute有很多AttributeType(),通过ProfileAttribute侧,并通过ProfileAttribute身边,我有many to one(很多类型可以属于很多ProfileAttributes)

回答

1

第一关闭,看起来很奇怪,ProfileAttributeType本身将包含一个ProfileAttribute的集合。也许它会有一个专用类型的属性的集合?

至于ProfileProfileAttribute之间的关系,属性应该是与该简档骨料相关联的值对象。这意味着这种关系是一对多的关系。换句话说,一个配置文件可以包含许多属性,但属性属于单个配置文件。属性本身可以按属性类型分组。如果存在与属性类型相关联的行为,则属性类型本身可以是实体聚合

相关问题