I need to append the results of one LINQ To SQL query to another on the database server side without reordering rows.
I need all errored orders first, then the pending orders.
var error = database.Orders.
Where(o => o.Status == XOrderStatus.Error).
OrderByDescending(o => o.Id);
var pending = database.Orders.
Where(o => o.Status == XOrderStatus.PendingReview).
OrderByDescending(o => o.Id);
var r = error.OrderedUnion(pending);
How I can implement the OrderedUnion()
method? Concat
, Union
and Distinct
methods completely eliminate OrderByDescending
call (by design).
I know it is possible to do with two ToArray()
calls, but I am interested having this done at the database level.