Sorting Entities: Ienumerable
Sorting Entities: Ienumerable
Using LINQ, developers can sort entities within a collection. The following code shows how you can take a collection of
books, order elements by book publisher name and then by title, and select books in an ordered collection. As a result of the
query, you will get an IEnumerable<Book> collection sorted by book publishers and titles.
Hide Copy Code
Hide Copy Code
This type of queries is useful if you have complex structures where you will need to order an entity using the property of a
related entity (in this example, books are ordered by publisher name field which is not placed in the book class at all).