- A) Sort a result set by one column in ascending order
- B) Sort a result set by one column in descending order
- 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
- G) Sort by ordinal positions of columns
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).
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.
ELINQ maps String's Length() function to TSQL's LEN.
But we can do it in Linq as previously:
ELINQ can do this, but it's definitely not a recommended way to sort: