Q: LINQ List Initializer not keeping order from initialization I have the following problem:
I select data from a DB, and for each item from the table, I create a model.
That model contains a list, wich contains the name in 3 languages.
But for some reason, LINQ does not keep my list initialization order.
Code:
db.SA_BamaType
            .Select(b => new BamaTypeModel()
            {
                id = b.p_bamatype,
                bamatypeNames = new List<string>()
                {b.bamatypeafdrukNL, b.bamatypeafdrukFR, b.bamatypeafdrukEN}
            }).ToList();

But when I debug this list, I see that the items are random switched from position. EN would become index 0, while NL should be index 0.
A dictionary would be the best use for this, but it seems LINQ can't translate a dictionary, that's why I used a List.

A: 
but it seems LINQ can't translate a dictionary

Of course it can:
db.SA_BamaType
            .AsEnumerable()
            .Select(b => new BamaTypeModel()
            {
                id = b.p_bamatype,
                bamatypeNames = new Dictionary<string, string>
                {
                    { "NL", b.bamatypeafdrukNL },
                    { "FR", b.bamatypeafdrukFR },
                    { "EN", b.bamatypeafdrukEN }
                }
            }).ToList();


A: var items = db.SA_BamaType
        .Select(b => 
        {
            id = b.p_bamatype,
            NL =  b.bamatypeafdrukNL,
            EN =  b.bamatypeafdrukEN,
            FR =  b.bamatypeafdrukFR
        }).ToList();
var models = items.Select(b=>
    new BamaTypeModel()
    { 
        id = b.id,
        bamatypeNames = new List<string>()
            {b.NL, b.FR, b.EN} 
    }
).ToList();

Small notes: new List() {..,..} is not a construction which LINQ2SQL can translate to SQL statements, so you can't use it in a LINQ query. If it worked for you, then you might transformed the query into objects already (as you noticed when AsEnumerable() is called).
 
And new List() {"A","B"} is the equivalent for:
var list = new List<string>();
list.Add("A");
list.Add("B");

So it should keep the declaration order ("A"  should be at position 0 and "B" should be at position 1).
