Skip to content

Latest commit

 

History

History
63 lines (39 loc) · 2.9 KB

File metadata and controls

63 lines (39 loc) · 2.9 KB

SQL Server ORDER BY

A) Sort a result set by one column in ascending order

There is a full integration between ELINQ and EF, so we can sort using Linq. This is usually preferrable since we usually want to sort the outer result set managed by EF (run and see the SQL to understand better).

B) Sort a result set by one column in descending order

It's convenient to return the "full" entities in ORM because otherwise there will be an "object hell". We will behave this way throughput this tutorial whenever it makes sense.

C) Sort a result set by multiple columns

D) Sort a result set by multiple columns and different orders

E) Sort a result set by a column that is not in the select list

F) Sort a result set by an expression

ELINQ maps String's Length() function to TSQL's LEN.

But we can do it in Linq as previously:

G) Sort by ordinal positions of columns

ELINQ can do this, but it's definitely not a recommended way to sort:


< BACK | HOME