1
I have 2 entities:
Itempedido and Product...
Using the Fluent API as I say to my Itempedido entity that she has a Product?
Note: The product entity cannot have dependencies, although 1 product can be in several itemPedido I do not want it to depend on an itemPedido to exist...
Product class:
namespace DTO
{
public class ProdutoDTO
{
public int produtoID { get; set; }
public int codigo { get; set; }
public string descricao { get; set; }
public decimal preco { get; set; }
}
}
Itempedido class:
namespace DTO
{
public class ItemPedidoDTO
{
public int itemPedidoID { get; set; }
public int quantidade { get; set; }
public int porcentagemDesconto { get; set; }
public int produdoID { get; set; }
public virtual ProdutoDTO produto { get; set; }
}
}
And where is the code?
– Leandro Angelo
I edited and put them.
– Márcio Sebastião
Okay, I don’t see any dependency on
ProdutoDTO
withItemPedidoDTO
, what is your doubt? There is no third "entity"PedidoDTO
, which will store theItemPedidoDTO
? Ps.: the attributepreco
should stay in theItemPedidoDTO
, otherwise if you change the price of a product, will change the value in all your orders already made.– Leandro Angelo
Yes there is the entity Pedidodto, I who removed from the code the request and virtual request thinking that I did not need to show since I did not talk about it... our well observed, nor noticed the question of price, vlw! My question is: "what I write with Fluent API in the class-specific Entity Framework configuration to say that Itempedido has a Product, but the Product has no dependency?"
– Márcio Sebastião