Page 1 of 1

Will the order of returned lists always be the same?

Posted: Mon 14 Jul 2014 16:00
by ashlar64
I have these two lines of code and I just want to confirm something...

Code: Select all

List<string> strings = context.Blah.Select(s => s.Time).ToList();
List<double> thing2s = context.Blah.Select(column).ToList();

This is getting data from a database. There is no chance that the order between the two lists might get out of whack? (Assuming that no modifications are done on the database during the time the 2 lines of code are run.)

So in other words if the lists were like:
strings thing2s
A 1
B 2
C 3

Is there a chance different orders of the lists being returned...something like this happening:


A 2
C 3
B 1

Re: Will the order of returned lists always be the same?

Posted: Tue 15 Jul 2014 08:12
by MariiaI
Please refer to http://www.sqlite.org/lang_select.html#orderby.
The article indicated that "If a SELECT statement that returns more than one row does not have an ORDER BY clause, the order in which the rows are returned is undefined."
This rule applies to other DBMSs, too (not only SQLite).