我是业务逻辑组件,使客户可以在网上订购。到目前为止,我简单的商业逻辑是这样的:订单和订单明细
public class Product
{
public int productID { get; }
public string name { get; set; }
//other properties here like address and such
}
public class Order
{
public int orderID { get; }
public Customer customer { get; set; }
public List<Product> OrderItems { get; set; }
//other properties go here
}
的Products
List不支持包含多个批量的产品订单。我如何在这里添加支持?我如何从客户端调用它?
感谢您的答复。 'Dictionary'总是需要一个密钥,该密钥必须是唯一的。这种情况下关键是什么? – Victor 2012-02-03 20:46:35
您应该使用ProductID作为关键字(假设您只希望您的订单中的每个产品都有一次)。它是一个整数,因此计算Dictionary内部使用的散列速度非常快,您也可以知道产品是否已经在您的订单中。 – Jay 2012-02-03 20:50:15
@Jay - 啊,所以它是'Dictionary'。是的,Dictionary在搜索时比列表快得多,但是当您实际下订单时,它不会增加复杂性,因为客户现在需要知道他们选择的每个项目的产品ID? –
Victor
2012-02-03 21:04:44