You can return both the list and the count as follows which is a proof of concept which deconstructs at the caller end.
public class EmpModel
{
public int EmployeeId { get; set; }
public string EmployeeName { get; set; }
public int EmployeeStatus { get; set; }
}
public class Operations
{
public static (List<EmpModel> list, int count) GetAllEmployees()
{
connection();
List<EmpModel> EmpList = new List<EmpModel>();
SqlCommand com = new SqlCommand("GetEmployees", con);
com.CommandType = CommandType.StoredProcedure;
SqlDataAdapter da = new SqlDataAdapter(com);
DataTable dt = new DataTable();
con.Open();
da.Fill(dt);
con.Close();
foreach (DataRow dr in dt.Rows)
{
EmpList.Add(
new EmpModel
{
EmployeeId = Convert.ToInt32(dr["EmployeeId"]),
EmployeeName = Convert.ToString(dr["EmployeeName"]),
EmployeeStatus = Convert.ToInt32(dr["EmployeeStatus"])
}
);
}
return (EmpList, EmpList.Count);
}
}
public class CallingClass
{
public static void Run()
{
var (list, count) = Operations.GetAllEmployees();
}
}