Implement counting in the EntityDAO