c# - How to get the count from IQueryable -
By the article I'm applying paging in my GridView, I need two methods:
Public IQueryable BindEmployees (integer startRowIndex, integer maximumRows) {EmployeeInfoDataContext dbEmp = new EmployeeInfoDataContext (); In the query query = dbEmp.Employees emp.DeptID on dbEmp.Departments join the department in dept.DeptID new selection equal {EmpID = emp.EmpID, EmpName = emp.EmpName, age = emp.ge, address = emp. Address, DeptName = dept.DepartmentName}; Return query. Skip (startRowIndex). (Maximum raus); } and
public integer GetEmployeeCount () {// How can I not repeat the above logic to get the numbers? } How can I get the value of the second method GetEmployeeCount from the first method BindEmployees ? I mean without repeating logic (query)
will be an option:
Public IQueryable BindEmployees (integer startRowIndex, integer maximumRows, count out integer) {EmployeeInfoDataContext dbEmp = new EmployeeInfoDataContext (); In the query query = dbEmp.Employees emp.DeptID on dbEmp.Departments join the department in dept.DeptID new selection equal {EmpID = emp.EmpID, EmpName = emp.EmpName, age = emp.ge, address = emp. Address, DeptName = dept.DepartmentName}; Count = query.Count (); Return query. Skip (startRowIndex). (Maximum raus); } The other option is to pass in the query paging function.
Comments
Post a Comment