In this post we shall
see on how to sort the results from a table using LINQ Query, this is similar to the ORDER BY clause in SQL Server. In EF Core LINQ queries we can
achieve this by using OrderBy.
Let us get the list of Employees in the Employee table sorted by the Name of the employee, this can be done using the following LINQ query.
Let us get the list of Employees in the Employee table sorted by the Name of the employee, this can be done using the following LINQ query.
SQL Query
SELECT * FROM [dbo].[Employee] ORDER BY Name
LINQ Query
var Employee = _context.Employee.OrderBy(e =>
e.Name);
SQL Query
SELECT * FROM [dbo].[Employee] ORDER BY Name DESC
SQL Query
SELECT * FROM [dbo].[Employee] ORDER BY Name DESC
LINQ Query
No comments:
Post a Comment