Use Select overload, which provides an index as well as a value. In this case, I would use AsEnumerable to get out of the database context, and that doesn't mean you want to do this work:
string[] alphaOrdinals = { "A", "B", "C", "D", "E" }; var query = dataContext.Cars .AsEnumerable() .Select((car, index) => new InventoryItem { Name = car.Name, Price = car.Price, UIElement = string.Format("Car {0} {1}", car.Id, alphaOrdinals[index]) }).ToList();
(You can change alphaOrdinals to a string without any code changes, by the way.)
source share