コード例 #1
0
        public static EmployeesResult GetEmployees(int skip, int take)
        {
            var ctx = new PubsDataContext();

            return new EmployeesResult
            {
                TotalRecords = ctx.employee.Count(),
                Employees = ctx.employee.Skip(skip).Take(take).Select(x => new Employee
                {
                    EmployeeID = x.emp_id,
                    FirstName = x.fname,
                    LastName = x.lname
                }).ToList()
            };
        }
コード例 #2
0
        public static Employee GetDetails(string employeeID)
        {
            var ctx = new PubsDataContext();
            var emp = ctx.employee.FirstOrDefault(x => x.emp_id == employeeID);

            if (emp == null)
            {
                return null;
            }

            return new Employee
            {
                EmployeeID = emp.emp_id,
                FirstName = emp.fname,
                LastName = emp.lname
            };
        }