5
I want to create a 1 x N mapping using the Fluent API of Entity Framework, something like: a shopping cart has several products.
In my class stroller, I have a navigation Property, which is a collection of products:
public class Produto
{
//Atributos do produto
}
public class Carrinho
{
//Outros atributos da classe
public virtual IEnumerable<Produto> Produtos { get; set; }
}
That same navigation Property could be modeled as a ICollection
:
public class Carrinho
{
//Outros atributos da classe
public virtual ICollection<Produto> Produtos { get; set; }
}
My question is: what is the difference between the two approaches?
imagining that it implements Ienumerabe...it can remove some product (complete) or add?
– ihavenokia
@ihavenokia do not know if I understand what you mean, but if it is what I thought it could not, there is a method in
IEnumerable
that allows this.– Maniero