Custom entity repository

Improvement of the code