简体   繁体   English

代表产品规格

[英]Representing product specifications

I need to extend my domain model: products may have different specifications. 我需要扩展我的域模型:产品可能具有不同的规格。 Eg motherboard specs are different from monitor specs. 例如,主板规格与显示器规格不同。

there are two entities: 有两个实体:

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

    // ..Price, Title, Manufacturer properties
}

where Category is 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; }
}

Is that a normal way to solve this I mean putting ICollection<String> Specs inside Category entity? 这是解决此问题的一种正常方法,我的意思是将ICollection<String> Specs放入Category实体中?

I'm using ASP.NET MVC & Raven DB . 我正在使用ASP.NET MVCRaven DB

If a set of specifications is part of a category of products then this is probably a good way to model it. 如果一组规格是产品类别的一部分,那么这可能是对它进行建模的好方法。

Though, a specification should probably be its own concept rather than a simple string (I say that without any knowledge of your specific requirements). 不过,规范可能应该是其自己的概念,而不是简单的字符串(我说这对您的特定要求一无所知)。

So, instead of an ICollection<string> have an ICollection<Specification> . 因此,可以使用ICollection<Specification>代替ICollection<string> ICollection<Specification>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM