April 2008
Intermediate to advanced
704 pages
17h 49m
English
Problem
You need to ensure that the results of a query are sorted appropriately, or you just need to sort the elements in a collection or array.
Solution
Create a standard LINQ query, such as the one described in recipe 6-1, and use the Order By clause to ensure that the data is ordered correctly.
How It Works
If you are familiar with query languages, you should recognize the Order By clause. It is used to specify how the data returned from a query is sorted. The Order By clause also supports the optional Ascending and Descending keywords, which specify in which direction the data is sorted. If omitted, Ascending is used by default. An Order By clause might look something like this:
Order By book.Title Ascending
The ...
Read now
Unlock full access