pure sql (in sqlite) is this:
select * from Employees order by case WorkDay
WHEN 'MON' then 0
WHEN 'TUE' then 1
WHEN 'WED' then 2
WHEN 'THU' then 3
WHEN 'FRI' then 4 END
result in a sql editor is okay and as expected
id| FullName | Department| WorkDay
7 Frank Bone C Block MON
8 Frank Bone D Block TUE
6 Frank Bone A Block FRI
9 Frank Bone E Block FRI
and C# code using SQLite.Net-PCL (Universal Windows Platform)
var rows =
conn.Query<Employees>("select * from Employees order by case WorkDay
WHEN 'MON' then 0
WHEN 'TUE' then 1
WHEN 'WED' then 2
WHEN 'THU' then 3
WHEN 'FRI' then 4 END").ToList();
//rows.ForEach(x => { listBox1.Add(x); }); rows appears in wrong/weird order in debug mode. this line not important and not the cause of wrong order.
rows appears in a weird/wrong order
I got this rows in a wrong order. Do you know what causes this weird order?
id| FullName | Department| WorkDay
6 Frank Bone A Block FRI
7 Frank Bone C Block MON
9 Frank Bone E Block FRI
8 Frank Bone D Block TUE
extra note: Model of table class (EF?)
public class Employees
{
[PrimaryKey, AutoIncrement]
public int id { get; set; }
public string FullName { get; set; }
[Indexed]
public string Department { get; set; }
public string WorkDay { get; set; }
}