本文介绍了ICollection< SomeModel>之间的差异vs List< SomeModel>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个模型让我们说客户和产品,这是客户和产品之间的一对多,即一个客户可以有多个产品

现在有什么区别

  public   class 客户
{
public int ID { get ; set ; }
public int 名称{ get ; set ; }
public ICollection< Products>产品{获取; set ;}

}

//
public class 客户
{
public int ID {获得; set ; }
public int 名称{ get ; set ; }
public 列表<产品>产品{获取; set ;}

}
// 哪个更适合dataModeling
解决方案




I Have a model Lets say Customer and Products and this is one to many between Customer and Products ie one customer can have multiple products
Now what is difference between

public class Customer
{
public int Id { get; set; }
public int Name{ get; set; }
public ICollection<Products> Product{ get ; set ;}

}

// and 
public class Customer
{
public int Id { get; set; }
public int Name{ get; set; }
public List<Products> Product{ get ; set ;}

}
//And Which is better for dataModeling
解决方案




这篇关于ICollection&lt; SomeModel&gt;之间的差异vs List&lt; SomeModel&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-21 23:30