public static ProductCollectionPaged GetProductsByDepartment(int pageNumber, int pageSize, int departmentNumber) { ProductCollectionPaged departmentProducts = new ProductCollectionPaged(); List <GetAllProductsByDepartmentDistinct_Result> result = new List <GetAllProductsByDepartmentDistinct_Result>(); using (FreeMarketEntities db = new FreeMarketEntities()) { result = db.GetAllProductsByDepartmentDistinct(departmentNumber) .ToList(); departmentProducts = SetProductDataDistinct(pageNumber, pageSize, result); return(departmentProducts); } }