protected function updateIdentityMap(EntityCollection $collection)
    {
        if ($collection->isEmpty()) {
            return $this;
        }

        foreach ($collection as $entity)
        {
            $this->repository->getIdentityMap()->set($entity);
        }
        return $this;
    }