【问题标题】:Representing product specifications代表产品规格
【发布时间】:2013-01-05 15:05:16
【问题描述】:

我需要扩展我的领域模型:产品可能有不同的规格。例如。主板规格与显示器规格不同。

有两个实体:

public class Product {
    public Guid Id { get; set; }
    public Category Category { get; set; }

    // ..Price, Title, Manufacturer properties
}

Category 在哪里

public class Category {
    // ..ctor to initialize this.Specs as List or as Dictionary

    public Guid Id { get; set; }
    public String Title { get; set; }
    public ICollection<String> Specs { get; set; }
}

这是解决这个问题的正常方法吗?我的意思是将ICollection&lt;String&gt; Specs 放入Category 实体中?

我正在使用ASP.NET MVCRaven DB

【问题讨论】:

    标签: c# .net ooad


    【解决方案1】:

    如果一组规格是产品类别的一部分,那么这可能是对其建模的好方法。

    不过,规范可能应该是它自己的概念,而不是一个简单的字符串(我这么说是在不了解您的具体要求的情况下)。

    所以,用ICollection&lt;Specification&gt; 代替ICollection&lt;string&gt;

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-07-02
      • 1970-01-01
      • 2015-03-24
      • 1970-01-01
      • 2012-04-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多