protected function addFilterToQueryBuilder(array $filter, QueryBuilder $queryBuilder)
    {
        $objectManager    = $this->getObjectManager();
        $entityClassAlias = $this->getEntityClassAlias();
        $classMetaData    = $objectManager->getClassMetadata($this->getEntityClass());
        $assocMappings    = $classMetaData->getAssociationMappings();

        $andExpressions = array();
        $paramCounter   = 0;

        foreach ($filter as $property => $value) {
            if (empty($value)) {
                continue;
            }

            if (!isset($assocMappings[$property])) {
                throw new \InvalidArgumentException('Unkown association "' . $property . '"');
            }
            $paramCounter++;
            $queryBuilder->andWhere($queryBuilder->expr()->eq($entityClassAlias . '.' .$property, '?' . $paramCounter));
            $queryBuilder->setParameter($paramCounter, $value);

        }

        return $paramCounter;
    }