Sachin Kalia

Sachin Kalia

  • NA
  • 24k
  • 9m

Iterate Through LIST

Nov 28 2012 8:00 AM
Hello Everyone

I've faced a strange problem with List<entityType> today.

i keep some values in List collections and whenever i tried to save value in Database using SqlCommand  .Update().it reshuffle the items of list and save it in random orders.

Which i surprise for me ,whilst i want to save the data in same order in which is.

e.g List<int> list = new List<int>();
list.Add(2); list.Add(3);         list.Add(4);
list.Add(5);
list.Add(6); foreach (int prime in list) // Loop through List with foreach { Console.WriteLine(prime); }
It saves the data in following orders as 2,3,6,4,5.

I have multiple records appox. 25 records in per batch.

Kindly help me to overcome on this issue and what is the reason behind this.

Thanks



Answers (1)