This topic shows how to sort query results. The example returns a collection of Product objects sorted alphabetically by the first letter of Product.ProductName.
 |
To run the code in this example, you need to create a new Telerik OpenAccess Domain Model based on the Northwind database. |
The following code is the LINQ example.
| C# |
Copy Code |
|
using ( EntitiesModel dbContext = new EntitiesModel() ) { var products = from product in dbContext.Products orderby product.ProductName select product; foreach ( Product product in products ) { Console.WriteLine( "ProductName: {0}", product.ProductName ); } } |
| VB.NET |
Copy Code |
|
Using dbContext As New EntitiesModel() Dim products = From product In dbContext.Products Order By product.ProductName Select product For Each _product As Product In products Console.WriteLine("ProductName: {0}", _product.ProductName) Next _product End Using |
See Also