How to use LINQ orderby clause to sort results in VB.NET

Sometimes Web developers have to sort the returned data. The LINQ orderby clause sorts the elements in the returned sequence according to the default comparer for the type being sorted. For example, the following query can be extended to sort the results based on the FirstName property. Because FirstName is a string, the default comparer performs an alphabetical sort from A to Z:

 

Dim qryNYClients = From client In clients

Where client.City = “New York”

Order By client.FirstName Ascending

Select client

 

Web developers can order the results in reverse order, from Z to A, by using the Order By…Descending clause.

If you want to host ASP.NET 4 application then you will need ASP.NET 4.0 hosting provider which supports .NET 4.0 Framework.