Will the order of returned lists always be the same?

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
ashlar64
Posts: 75
Joined: Thu 04 May 2006 18:56

Will the order of returned lists always be the same?

Post by ashlar64 » Mon 14 Jul 2014 16:00

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

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

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

Post by MariiaI » Tue 15 Jul 2014 08:12

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).

Post Reply