I'm having trouble creating my models.
Let's imagine that I have 4 different types of products (Here like A, B, C and D)
public class Produto
{
public int ProdutoId { get; set; }
public TipoProduto TipoProduto { get; set; } //enum tipo
}
However, the Type A products (% w / o%) can be disassembled and thus create 4 new pieces, in which I also want to register. (until then I'm going to register a model called ProdutosTipoAPartes) I thought about creating another Model where I could store the Id of the base product
public class ProdutoTipoA
{
public int ProdutoTipoAId { get; set; }
public int ProdutoId { get; set; }
//caracteristicas específicas do tipo A
public virtual Produto Produto { get; set; }
}
products of type B
public class ProdutoTipoB
{
public int ProdutoTipoBId { get; set; }
public int ProdutoId { get; set; }
//caracteristicas específicas do tipo B
public virtual Produto Produto { get; set; }
}
Is this approach correct? in the Products model would I have some kind of virtual relationship with the other types TipoProduto==A
, A
, B
or C
?
Or better I create:
public class ProdutoBase
{
public int ProdutoId { get; set; }
public TipoProduto TipoProduto { get; set; } //enum tipo
public string Serial { get; set; }
}
and ProductsA, ProductsB inherit base?
public class ProdutoTipoA : ProdutoBase
{
//caracteristicas específicas do tipo A
}
And to complete, I will have the orders, which will be linked to the Products, so it would be complex if I had several types of Model Products. I do not know which way to go.
Update: The options I see are:
- Create Base Class and products A, B, C, and D inherit
- Create a Product and other products that are hierarchically inferior, as if it were child products.
- Create 4 separate products and turn my life into a madness ..