These are the generated SQLs for both queries, as you can see the second doesn't have an ORDER BY clause:
SELECT "Extent1"."Acum"
FROM "public"."Transactions"
AS "Extent1" ORDER BY "Extent1"."Date" DESC
SELECT CASE
WHEN ("Project1"."C1" IS NULL)
THEN (0::numeric)
ELSE ("Project1"."Acum") END AS "C1"
FROM (SELECT 1 AS "C") AS "SingleRowTable1"
LEFT OUTER JOIN
(SELECT "Extent1"."Acum", 1::int2 AS "C1" FROM "public"."Transactions" AS "Extent1") AS "Project1"
ON TRUE = TRUE
I would guess it's a bug in Entity Framework itself rather than in Npgsql's EF provider. Could you try to do the same when using SQL Server's EF provider?
The following query is returned correctly ordered:
But this other query not:
These are the generated SQLs for both queries, as you can see the second doesn't have an ORDER BY clause: