public function count($class, DataRequest $dataRequest)
    {
        try {
            $request = clone $dataRequest;
            
            $request->setPage(0);
            $request->setNumberOfEntries(0);
            
            $queryBuilder = $this->entityManager->getQueryBuilder();
            $this->entityManager->buildDataRequestQuery($request, $queryBuilder, $class, 'a');
            
            // Count
            $queryBuilder->select($queryBuilder->expr()->count('a.id'));

            $data = $queryBuilder->getQuery();
            if ($data === false) {
                return 0;
            }

            return $data->getSingleScalarResult();
        } catch (\Exception $e) {
            throw new Exception('Cannot count the access entities for the given data request.', 0, $e);
        }
    }