I have the following employee object.
Emp_Number Name Designation salary
1 aa Employee 30000
2 a1 Manager 60000
3 b1 Employee 35000
6 b2 Employee 32000
5 c1 Manager 40000
This is the code to get the details.
public List<Employee> GetEmployeeDetailsAllDesc()
List<Employee> employeeDetailAllDesc = new List<Employee>();
string connectionString = GetConnection();
string queryString = "SELECT * "
+ " FROM employee order by Emp_Number desc";
using (SqlConnection connection = new SqlConnection(
SqlCommand command = new SqlCommand(
SqlDataReader reader = command.ExecuteReader();
if (reader == null || !reader.HasRows)
employeeDetailAllDesc = null;
return employeeDetailAllDesc ;
Employee employeeAllDesc = new Employee ();
employeeAllDesc.Emp_Number = (int)reader["Emp_Number"];
employeeAllDesc.Name = reader["Name"].ToString();
I need to get the 3 different types of result from this object.
Result 1: Employee Detail order by Emp_Number Ascending order
Result 2: Employee Detail order by Emp_Number Descending order
Result 3: Employee Detail Designation ='Employee'
I do not want to use the three different method to get the above details and it will hit the DB three times. So how can I achieve this in single hit ?