Guest User

Guest User

  • Tech Writer
  • 357
  • 121.1k

Quantity property

May 8 2012 10:02 AM
Hi

I need help in getting the total quantity for each item persisted to the OrderDetail table in the DB.

Given the following:-

List<OrderDetail> orderDetails // Local variable to hold output

usersShoppingCart.SubmitOrder(User.Identity.Name, out orderDetails);

   foreach(OrderDetail od in orderDetails)
   {
      int quantity = od.Quantity;
   } 

The quantity variable only holds 1 quantity at a time rather than the total quantity.

For example if I had 2 items in my cart, both with quanitities of 1, only 1 quantity will get stored in the quantity variable but I would like 2, 1 per item.

Any help in achieving this would be great.

Thanks

Steven

Answers (4)