O'Reilly logo

C# 5.0 Unleashed by Bart De Smet

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Ordering

One of the most commonly used query operations in the world of databases is applying ordering to the elements or records. Obviously, LINQ provides for this, as well:

var memoryHungry = from process in Process.GetProcesses()                   orderby process.ProcessName, process.WorkingSet64 descending                   select process;

The preceding query expression translates into the use of two operators, OrderBy and ThenByDescending. Their respective roles will become apparent in just a moment:

var memoryHungry = Process.GetProcesses()                   .OrderBy(process => process.ProcessName)                   .ThenByDescending(process => process.WorkingSet64);

OrderBy and ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required