1

사용자가 각 ProductType 개체에 "ProductTypeProperties"목록을 집계해야하며 각 ProductTypeProperty 개체에 "ProductType"개체가 있어야하는 "ProductType"개체를 만들 수 있어야하는 도메인이 있습니다. 집계 된 "ProductTypePropertyValues"목록도메인 모델링 도움말 : Product & ProductType & ProductyTypeProperties 및 ProductyTypePropertyValues ​​

사용자는 "Product"개체를 만들고 거의 ProductTypes와 연결할 수 없습니다.

사용자가 Product를 몇 가지 ProductTypes와 연결할 때 사용자는 Product 개체에 대한 ProductTypeProperties 값을 지정할 수 있습니다. 나는 그런를 설계하는 방법을 잘 모르겠어요

을 "문자열/정수/소수점 입력"을 "다중 선택"및 "한 선택"

ProductTypeProperties처럼, 다른 선택 모드에 속하는 값을 가질 수있다 도메인 개체 모델. 특히 Product 객체의 ProductType 속성 값을 Product 객체에 적용하는 방법

저는 현재 SQL/Document/Object/Graph 데이터베이스를 자유롭게 선택할 수 있으므로 객체 도메인 모델에 대해서만이 시점에서 지속성에 대해 신경 쓰지 않습니다.

는 객체 구조는 이제 다음과 같습니다

ProductType 
    List<ProductTypeProperty> 
     List<ProductTypePropertyValue> 

Product 
    List<ProductType> 

내가 지금 사용하는 C#을 클래스 정의는 다음과 같습니다

그것은 객체의 클래스/객체 구조를 적용하려고처럼 보인다
public class Product { 
    public string Name { get; set; } 
    public List<ProductType> AssociatedProductTypes { get; set; } 
    // how to apply ProductType's property values to a 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; } 
} 

"ProductType"은 "클래스"이고 "Product"는 인스턴스 "ProductTypes"및 "Inherit"속성이 될 수있는 "개체"이며 연결된 각 제품 유형에서 사용 가능한 값입니다.

저는 이처럼 객체 모델을 사용하지 않으므로 올바르게 수행하는 방법이 매우 흥미 롭습니다. 아이디어와 제안을 보내 주셔서 감사합니다.

+0

찾고있는 구조 (여러 제품 유형, 여러 속성이있는 제품 유형, 가능한 여러 값이있는 제품)를 올바르게 반영한 개체 모델이 이미있는 것으로 보입니다. 이미 모델링했다면, 그 질문은 무엇입니까? – edutesoy

답변

2

다음과 같이 당신은 ProductTypeProperty를 매핑 할 수 있습니다 :

TValue이 (문자열, 진수, INT, 또는 여러 선택이 될 수있다) 속성 값의 유형을 결정하는 일반적인 기본 속성 클래스 :

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; 
     } 
    } 
을 재산의 각 유형에 대한

중첩 클래스를 생성, 간단한 문자열 속성에 대한 예를 들어, 당신은 만들 수 있습니다

public class ProductTypeStringProperty : ProductTypePropertyBase<string> 
{ 
    public ProductTypeStringProperty(string name, string value) : base(name, value) 
    { 
    } 
} 

을 m과 같은 복잡한 속성 유형 당신이 구현할 수있는 최종 선택 사항 :

public class ProductTypeMultipleChoiceProperty : ProductTypePropertyBase<MultipleChoiceValue> 
{ 
    public ProductTypeMultipleChoiceProperty(string name, MultipleChoiceValue value) : base(name, value) 
    { 
    } 
} 

여기서 MultipleChoiceValue는 문자열 목록을 나타내는 다른 유형입니다.