4
Answers

Quantity property

S

S

12y
1.1k
1
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)