本文整理汇总了C#中Order.AddOrderLineItem方法的典型用法代码示例。如果您正苦于以下问题:C# Order.AddOrderLineItem方法的具体用法?C# Order.AddOrderLineItem怎么用?C# Order.AddOrderLineItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Order
的用法示例。
在下文中一共展示了Order.AddOrderLineItem方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Example
public void Example()
{
// Complex model
var customer = new Customer
{
Name = "George Costanza"
};
var order = new Order
{
Customer = customer
};
var bosco = new Product
{
Name = "Bosco",
Price = 4.99m
};
order.AddOrderLineItem(bosco, 15);
// Configure AutoMapper
Mapper.CreateMap<Order, OrderDto>();
// Perform mapping
OrderDto dto = Mapper.Map<Order, OrderDto>(order);
dto.CustomerName.ShouldEqual("George Costanza");
dto.Total.ShouldEqual(74.85m);
}
示例2: Example
public void Example()
{
// Complex model
var customer = new Customer
{
Name = "John Doe"
};
var order = new Order
{
Customer = customer
};
var tv = new Product
{
Name = "Sony",
Price = 4.99m
};
order.AddOrderLineItem(tv, 15);
// Configure AutoMapper
Mapper.CreateMap<Order, OrderDto>();
// Perform mapping
OrderDto dto = Mapper.Map<Order, OrderDto>(order);
dto.CustomerName.ShouldEqual("John Doe");
dto.Total.ShouldEqual(74.85m);
}