我正在为我的GridView实现分页。从这篇文章中,我需要两个方法:
public IQueryable BindEmployees(int startRowIndex, int maximumRows)
{
EmployeeInfoDataContext dbEmp = new EmployeeInfoDataContext();
var query = from emp in dbEmp.Employees
join dept in dbEmp.Departments
on emp.DeptID equals dept.DeptID
select new
{
EmpID = emp.EmpID,
EmpName = emp.EmpName,
Age = emp.Age,
Address = emp.Address,
DeptName = dept.DepartmentName
};
return query.Skip(startRowIndex).Take(maximumRows);
}
并且
public int GetEmployeeCount()
{
// How can I not repeat the logic above to get the count?
}
我怎样可以从第一个方法BindEmployees
获取第二个方法GetEmployeeCount
的值?我的意思是不重复逻辑(查询)的情况下。