Q: List.Add() does not add the elements in order? I have a List<OrderItem> orderItems that contains all the items from the database for the batch of orders I'm working on.
I also have a Dictionary<int, Order> order_list that contains the orders the items need to go in.
The Order object has a List<OrderItem> member named OrderItems.
I have an Order with an ID of 1 in order_list.
I have three items in OrderItems that carry the order_id of 1 with three different product variant id's.
The fetch from the database retrieves the items in the order of the product variant id.  This means that orderItems looks something like this: 

[0] => orderId = 1, productVariantId = 4 [1] => orderId = 1,
  productVariantId = 5 [2] => orderId = 1, productVariantId = 6

In my code I have a loop that goes through the orderItems and assigns them to their respective orders:
foreach (OrderItem orderItem in orderItems)
{
    if (order_list.ContainsKey(orderItem.OrderId))
    {
        order_list[orderItem.OrderId].OrderItems.Add(orderItem);
    }
}

After the loop executes, I find the OrderItems member for order 1 looks like this:

[0] => orderId = 1, productVariantId = 5 [1] => orderId = 1,
  productVariantId = 6 [2] => orderId = 1, productVariantId = 4

I stepped through the code carefully and watched it insert the elements.  Here is what I saw it do:
Iteration 1 for product variant 4, the final OrderItems looked like this:

[0] => orderId = 1, productVariantId = 4

Iteration 2 for product variant 5, the final OrderItems looked like this:

[0] => orderId = 1, productVariantId = 5 [1] => orderId = 1,
  productVariantId = 4

Iteration 3 for product variant 6, the final OrderItems looked like this:

[0] => orderId = 1, productVariantId = 5 [1] => orderId = 1,
  productVariantId = 6 [2] => orderId = 1, productVariantId = 4

My research has led me to conclude this should not be behaving such because the List<T>.Add() method should always add the new element to the END of the list.
Can anyone tell me why the List<T>.Add() does not add the elements in order in my application?

A: The first line in the MSDN docs says "Adds an object to the end of the List<T>", so yes, order is maintained.  You have a lot more going on in your code than simple list manipulation, but your sample is not complete enough to tell you what your mistake is.

A: I find that question does not provide enough code. Since I cannot comment, here is my interpretation, via LinqPad:
void Main()
{
    //populate
    var dbOrderItems = new List<OrderItem>();
    dbOrderItems.Add(new OrderItem { OrderId = 1, ProductVariantId = 4 });
    dbOrderItems.Add(new OrderItem { OrderId = 1, ProductVariantId = 5 });
    dbOrderItems.Add(new OrderItem { OrderId = 1, ProductVariantId = 6 });
    dbOrderItems.Add(new OrderItem { OrderId = 2, ProductVariantId = 10 });
    dbOrderItems.Add(new OrderItem { OrderId = 2, ProductVariantId = 11 });
    dbOrderItems.Dump();

    Dictionary<int, Order> order_list = new Dictionary<int, Order>();
    foreach(OrderItem orderItem in dbOrderItems)
    {
        if (order_list.ContainsKey(orderItem.OrderId))
        {
            var currOrderItems = order_list[orderItem.OrderId].OrderItems;
            if (currOrderItems.Contains(orderItem) == false)
            {
                // order exists, add new order item
                currOrderItems.Add(orderItem);
                order_list[orderItem.OrderId].OrderItems = currOrderItems; 
            }
        }
        else
        {
            // new order
            order_list.Add(orderItem.OrderId, new Order { OrderId = orderItem.OrderId, OrderItems = new List<OrderItem> { orderItem } });
        }
    }

    order_list.Dump();

}

// Define other methods and classes here
public class OrderItem
{
    public int OrderId {get;set;}
    public int ProductVariantId {get;set;}
}

public class Order
{
    public int OrderId {get;set;}
    public List<OrderItem> OrderItems {get;set;}
}

Output for Order 1:
OrderId ProductVariantId 
1 4 
1 5 
1 6 

Output for Order 2:
OrderId ProductVariantId 
2 10 
2 11 

Now, what was the question?
