c# - Domain Modelling Help: Product & ProductType & ProductyTypeProperties & ProductyTypePropertyValues -


i have problem domain user should able create "producttype" object each producttype object should have list of "producttypeproperties" aggregated , each producttypeproperty object should have list of "producttypepropertyvalues" aggregated.

after user able create "product" object , associate few producttypes it.

when user associates product few producttypes, user able specify values of producttypeproperties product object.

producttypeproperties have values belongs different select modes, like: "one-choose", "multiple-choose" , "string / integer / decimal input"

i'm not sure how design such domain object model. how apply producttype's property values on product object.

i don't mind persistence @ time, object domain model, i'm free choose sql/document/object/graph database.

the object structure looks this:

producttype     list<producttypeproperty>         list<producttypepropertyvalue>  product     list<producttype> 

the c# classes definition use is:

public class product {     public string name { get; set; }     public list<producttype> associatedproducttypes { get; set; }     // how apply producttype's property values product object? }  public class producttype {     public string name { get; set; }     public list<producttypeproperty> aggregatedproperties { get; set; } }  public class producttypeproperty {     public string name { get; set; }     public list<producttypepropertyvalue> aggregatedavailablevalues { get; set; } }  public class producttypepropertyvalue {     public string name { get; set; } } 

it looks trying apply class/object structure in objects, "producttype" "class" , "product" "object" can instance "producttypes" , "inherit" properties , available values each of associated product types.

i never doing object model this, it's interesting how right. ideas , suggestions.

you can map producttypeproperty follows:

a generic base property class, tvalue determine type of property value (could string, decimal, int, or multiple choice):

    public abstract class producttypepropertybase<tvalue>     {         public string name { get; set; }         public tvalue value { get; set; }          protected producttypepropertybase(string name, tvalue value)         {             name = name;             value = value;         }     } 

for each type of property create nested class, example simple string property can create:

public class producttypestringproperty : producttypepropertybase<string> {     public producttypestringproperty(string name, string value) : base(name, value)     {     } } 

for complex property type multiple choices can implement:

public class producttypemultiplechoiceproperty : producttypepropertybase<multiplechoicevalue> {     public producttypemultiplechoiceproperty(string name, multiplechoicevalue value) : base(name, value)     {     } } 

where multiplechoicevalue type represents list of strings example.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -